I am building a Rust library that needs to call some C functions with Rust objects. I have a trait with a function that calls the C function, the C function is defined in Rust as follows:
extern {
fn process_trait(my_trait: MyTrait);
}
The idea is that the user can implement the trait for his struct and then call the C functions (basically, the C then calls some other Rust back, which calls some of the Trait functions). The error here is: the trait core::marker::Sized is not implemented for the type Self
, because I am passing *self
to process_trait. Am I doing something wrong? I tried changing this a bit, even casting, I am getting either this error or wrong type.
I think the problem is that it's supposed to be heap allocated, no? The only thing I am trying to avoid is the API looking ugly. The user should just be able to
struct MyUnit;
impl MyTrait for MyUnit...
MyUnit.callC();