Hello I'm trying to use a rust library in C++ project by using cxx bridge. But Cargo won't let this struct and function to be inside it. How can I put KdTree inside cxx bridge which is provided by kiddo?
use kiddo::{distance::squared_euclidean, KdTree, ErrorKind};
// use time::Instant;
use csv::ReaderBuilder;
use serde_derive::{Deserialize, Serialize};
use std::error;
use std::fmt;
use std::path::Path;
#[cxx::bridge]
mod ffi{
struct kdtree<'a> {
tree: KdTree<f64, &'a Record, 2>,
}
extern "Rust" {
fn from_path<P: AsRef<Path>>(file_path: P) -> Result<Locations, Box<dyn error::Error>>;
}
Cargo leave error message like below:
error[cxxbridge]: unsupported type
┌─ src/lib.rs:43:15
│
43 │ tree: KdTree<f64, &'a Record, 2>,
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^ unsupported type
error[cxxbridge]: extern function with generic parameters is not supported yet
┌─ src/lib.rs:48:9
│
48 │ fn from_path<P: AsRef<Path>>(file_path: P) -> Result<Locations, Box<dyn error::Error>>;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ extern function with generic parameters is not supported yet
And about configuration, I just added some dependencies in Cargo.toml like this
[dependencies]
kiddo = "0.2.5"
csv = "1.2.0"
# time = "0.3.7"
serde = "^1.0"
serde_derive = "^1.0"
corrosion = "0.0.2"
cxx = "1.0"
kdtree = "0.6"
[build-dependencies]
cxx-build = "1.0"