You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's often useful to interoperate with C libraries that may return enum values; in this case you do not necessarily have a guarantee that the returned value is a valid variant, and it may be useful to preserve the original value, e.g. for round-tripping data.
...and then explicitly implement From<u32> for Foo and From<Foo> for u32. Here's a library that provides a macro for defining enums in this way: https://github.com/cimbul/tartan-c-enum
This seems like something that would be useful for UniFFI to support as well.
The text was updated successfully, but these errors were encountered:
It's often useful to interoperate with C libraries that may return enum values; in this case you do not necessarily have a guarantee that the returned value is a valid variant, and it may be useful to preserve the original value, e.g. for round-tripping data.
It's simple enough to represent this in Rust:
...and then explicitly implement
From<u32> for Foo
andFrom<Foo> for u32
. Here's a library that provides a macro for defining enums in this way: https://github.com/cimbul/tartan-c-enumThis seems like something that would be useful for UniFFI to support as well.
The text was updated successfully, but these errors were encountered: