Skip to content
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

UX: Cloneable traits [age crate] #353

Open
mberry opened this issue Nov 16, 2022 · 2 comments
Open

UX: Cloneable traits [age crate] #353

mberry opened this issue Nov 16, 2022 · 2 comments

Comments

@mberry
Copy link

mberry commented Nov 16, 2022

For ergonomics it would nice to be able to clone the Identity and Recipient traits, had a few usecases where it becomes unwieldy without it.

Probably the easiest way to implement this is with https://github.com/dtolnay/dyn-clone,

There is also a convenience macro wrapper for that crate here: https://github.com/kardeiz/objekt-clonable, which ends up with minimal extra code and just adding supertraits, such as:

#[clonable]
pub trait Recipient: Clone {
 ...
}

Would also have to derive clone on some internal structs that use it too, Stanza, Header, BaseDecryptor, etc.

Could whip up a draft PR if this is something you be interested in. Thanks.

@str4d
Copy link
Owner

str4d commented Aug 28, 2024

I'm not sure I want to require that Identity and Recipient are cloneable. That might be reasonable for some (or even most) Recipient implementations, but Identity implementations are much more likely to not be suitable for cloning (e.g. if they wrap a connection to an HSM or KMS; the latter could also be the case for Recipient).

What specific use cases did you encounter that were unwieldy without a Clone bound?

str4d added a commit that referenced this issue Aug 30, 2024
This aligns it with `Decryptor`, and means that recipients can be
used to encrypt multiple files without cloning.

Part of #353.
@str4d
Copy link
Owner

str4d commented Aug 30, 2024

After #523, it will no longer be necessary to clone Recipient impls in order to use them across multiple files (aligning the API with how Identity was used for decryption).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants