-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deriving uniffi::Record
together with ZeroizeOnDrop
does not compile. Solvable?
#2080
Comments
UniFFI could certainly generate code that works without destructuring, but for zeroize in particular I think you'd be defeating the purpose of that derive since UniFFI would be creating copies of the bytes that don't get zeroized on drop. |
Right that is what I feared, but maybe some optimization could be done in "that realm", e.g. if UniFFI could check if the Source or Target implements Zeroize and could use it on any copies, so that only the the resulting Target / Source contains those bytes, but any "ephemeral copies" are zeroed out during the conversion? |
It's impossible for a macro to check whether a trait is implemented, trait solving happens after macro expansion (trait solving depends on the output of all macros in a given source tree incl. dependencies). It would be possible to introduce |
Right that makes sense, thanks for explaining @jplatte ! I'm still fairly new to Rust (started in December last year) and have only beeng doing macros since February.
Yes that would really be amazing! I might try to give a PR a go later on! |
I'd suggest you start with a justification first - I can only speak for myself, but @jplatte is correct regarding appetite - I doubt we want to support every cool-sounding crate out there. In this specific case, the hurdle to overcome is already noted above - uniffi makes many copies of records with the expectation that many of them live in the foreign code - in these scenarios, zeroize seems, frankly, pointless. |
I've recently tried to add Zeroize on my UniFFI records / enums, like so:
Results in compilation error:
Hmm.... is this even solvable?
The text was updated successfully, but these errors were encountered: