-
Notifications
You must be signed in to change notification settings - Fork 119
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
investigate ways to avoid heap allocations #16
Comments
It would be an option to use Maybe associated types would help? |
@vks I think we'd need If you have any suggestions for associated types I'm all ears! Another thought I had was to simply disallow external resolvers and use |
related to #62 |
Why is |
@isislovecruft yep, it's purely for ergonomic reasons. I'd love to use something like associated traits and maybe a convenience macro to be able to drop the |
If you want trait objects without heap allocations, one option is an enum CipherBackends {
#[cfg(feature = "backend1")]
....
} impl core::ops::Deref for CipherBackends {
type Target = dyn Cipher;
fn deref(&self) -> &(dyn Cipher + 'static) {
match self {
#[cfg(feature = "backend1")]
....
}
}
} This should work more or less the same as Note that this does have the advantage that the size of |
@tarcieri the reason I didn't choose this method in the original design is because I wanted the option for people to implement their own crypto backends if snow didn't provide any that fit their needs. If it's totally clear that flexibility isn't necessary, we could definitely switch to something like this. |
Unfortunately I think you need either |
Right now for the sake of cleaner syntax, there's allocation being done using
Box
structs to avoid forcing users of snow to specify a ton of ugly generics when they store sessions in their own structs, for example.The text was updated successfully, but these errors were encountered: