Decryptable

Trait Decryptable 

Source
pub trait Decryptable<'a>: Entity {
    type DecryptableFrom: 'a + Decrypting<'a, DecryptedForm = Self>;
}
Expand description

Helper trait for restoring from an encrypted form of this struct.

This is mainly useful so that the encrypted form does not need to be named, or even nameable.

This is quite likely to be handled automatically by a macro, depending on how annoying it is to implement everywhere.

§Example

Extending the example from Decrypting:

// Foo is an Entity
struct Foo { ... }

#[derive(serde::Serialize)]
struct EncryptedFoo<'de> { ... }

impl<'de> Decrypting<'de> for EncryptedFoo<'de> {
    type DecryptedForm = Foo;
    fn decrypt(self, cipher: &aes_gcm::Aes256Gcm) -> CryptoKeystoreResult<Foo> { ... }
}

impl<'de> Decryptable<'de> for Foo {
    type DecryptableFrom = EncryptedFoo<'de>;
}

EncryptedFoo now no longer needs to appear in external code:

let foo = serde_json::from_str::<Foo::DecryptableFrom>(json)?.decrypt(cipher)?;

Required Associated Types§

Source

type DecryptableFrom: 'a + Decrypting<'a, DecryptedForm = Self>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Decryptable<'static> for E2eiCrl

Source§

type DecryptableFrom = E2eiCrlDecrypt

Source§

impl Decryptable<'static> for E2eiIntermediateCert

Source§

type DecryptableFrom = E2eiIntermediateCertDecrypt

Source§

impl Decryptable<'static> for PersistedMlsGroup

Source§

type DecryptableFrom = PersistedMlsGroupDecrypt

Source§

impl Decryptable<'static> for ProteusSession

Source§

type DecryptableFrom = ProteusSessionDecrypt

Source§

impl Decryptable<'static> for StoredBufferedCommit

Source§

type DecryptableFrom = StoredBufferedCommitDecrypt

Source§

impl Decryptable<'static> for StoredE2eiEnrollment

Source§

type DecryptableFrom = StoredE2eiEnrollmentDecrypt

Source§

impl Decryptable<'static> for StoredEpochEncryptionKeypair

Source§

type DecryptableFrom = StoredEpochEncryptionKeypairDecrypt

Source§

impl Decryptable<'static> for StoredKeypackage

Source§

type DecryptableFrom = StoredKeypackageDecrypt