Implement ReprC for re-exported types #166
-
I'm generating C bindings for a Rust crate that uses repr(C) types from it's dependencies. Can safer_ffi generate bindings for these types? Currently, the only way I can solve this is by writing an identical struct with For example, how would you bind a function that returns this type? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Sadly the way trait impls work make it so you cannot implement So what you're doing is currently the only direct workaround on your end. That being said, you could try the same solution as for
Automating the "twin struct" approachThis could be achieved with an approach similar to that of |
Beta Was this translation helpful? Give feedback.
Sadly the way trait impls work make it so you cannot implement
ReprC
for it, and I cannot realistically do it myself, unless I anticipated this and depended on that crate specifically. This is the "{De,}Serialize
problem"; only,serde
is popular enough to let library authors think of this, whereas other crates not necessarily.So what you're doing is currently the only direct workaround on your end.
That being said, you could try the same solution as for
{De,}Serialize
:patch
directive to depend on your fork;#[derive_ReprC]
invocations;safer-ffi
feature:#[cfg_attr(feature = "safer-ffi", ::safer_ffi::derive_ReprC)]