-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
Hi,
firstly, thanks for the great library, which is already a huge help in simplifying my ffi code!
I would like to request a feature that would let me avoid having to duplicate a lot of struct definitions.
What I have is a bunch of structs containing Strings and Vecs and deriving Serialize and Deserialize, which I also want to use in the ffi interface and right now I have to duplicate them changing every String and Vec with their repr_c counterpart and implementing a From impl to convert them. For example:
#[derive(Serialize, Deserialize)]
struct ExampleData {
name: String,
list: Vec<String>,
}
mod ffi {
#[derive_ReprC]
#[repr(C)]
struct ExampleData {
name: repr_c::String,
list: repr_c::Vec<repr_c::String>,
}
impl From<super::ExampleData> for ExampleData {
fn from(value: super::TestData) -> Self {
Self {
name: value.name.into(),
list: repr_c::Vec::from(value.list.into_iter().map(Into::<repr_c::String>::into).collect::<Vec<repr_c::String>>()),
}
}
}
}It would be great if I could simply do this instead:
#[derive_ReprC]
#[repr(C)]
#[derive(Serialize, Deserialize)]
struct ExampleData {
name: repr_c::String,
list: repr_c::Vec<repr_c::String>,
}But this is not possible right now since repr_c::String and repr_c::Vec do not implement Serialize and Deserialize.
MeguminSama
Metadata
Metadata
Assignees
Labels
No labels