I am writing an extern lib for Polars in Rust (for consumption by Raku::Dan) and would like to get out an opaque container for a LazyFrame object by calling df.lazy().
use polars::prelude::*;//{CsvReader, DataType, DataFrame, Series};
use polars::prelude::{Result as PolarResult};
use polars_lazy::prelude::*;
// LazyFrame Container
pub struct LazyFrameC {
lf: LazyFrame,
}
impl LazyFrameC {
fn new(ptr: *mut DataFrameC) -> LazyFrameC {
LazyFrameC {
lf: (*ptr).df.lazy(),
}
}
}
// extern functions for LazyFrame Container
#[no_mangle]
pub extern "C" fn lf_new(ptr: *mut DataFrameC) -> *mut LazyFrameC {
let df_c = unsafe {
assert!(!ptr.is_null());
&mut *ptr
};
Box::into_raw(Box::new(LazyFrameC::new(ptr)))
}
Does not work, gives the error:
error[E0599]: no method named `lazy` found for struct `polars::prelude::DataFrame` in the current scope
--> src/lib.rs:549:27
|
549 | lf: (*ptr).df.lazy(),
| ^^^^ method not found in `polars::prelude::DataFrame`
Here's my Cargo.toml (edit)...
[package]
name = "dan"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
libc = "0.2.126"
polars = "0.21.1"
polars-core = "0.22.7"
polars-lazy = "0.22.7"
[lib]
name = "dan"
path = "src/lib.rs"
crate-type = ["cdylib"
Any steer on pinning down the correct library would be much appreciated!
DataFrameC
. Note also that you are missing#[repr(C)]
onLazyFrameC
. – ColoCargo.toml
? – Severn#[repr(C)]
on LazyFrameC since I am implementing a proxy pattern with opaque objects ... so the only thing I need on the raku side for this Container is a ptr and then implement a method call and callback interface. Where I do pass data (args and return) I useCStr
andCArray
and native C types likei32
. – Pneuma