Struct encrypted_message::EncryptedMessage

source ·
pub struct EncryptedMessage<P: Debug + DeserializeOwned + Serialize, S: Strategy, K: KeyConfig> { /* private fields */ }
Expand description

Used to safely handle & transport encrypted data within your application. It contains an encrypted payload, along with a nonce & tag that are used in the encryption & decryption processes.

Implementations§

source§

impl<P: Debug + DeserializeOwned + Serialize, S: Strategy, K: KeyConfig> EncryptedMessage<P, S, K>

source

pub fn encrypt_with_key_config( payload: P, key_config: &K ) -> Result<Self, EncryptionError>

Creates an EncryptedMessage from a payload, using the AES-256-GCM encryption cipher.

§Errors
source

pub fn decrypt_with_key_config( &self, key_config: &K ) -> Result<P, DecryptionError>

Decrypts the payload of the EncryptedMessage, trying all available keys in order until it finds one that works.

§Errors
source

pub fn with_new_payload_and_key_config( self, payload: P, key_config: &K ) -> Result<Self, EncryptionError>

Consumes the EncryptedMessage & returns a new one with the same encryption strategy, but with a new encrypted payload.

See EncryptedMessage::encrypt_with_key_config for more information.

source§

impl<P: Debug + DeserializeOwned + Serialize, S: Strategy, K: KeyConfig + Default> EncryptedMessage<P, S, K>

source

pub fn encrypt(payload: P) -> Result<Self, EncryptionError>

This method is a shorthand for EncryptedMessage::encrypt_with_key_config, passing &K::default() as the key configuration.

source

pub fn decrypt(&self) -> Result<P, DecryptionError>

This method is a shorthand for EncryptedMessage::decrypt_with_key_config, passing &K::default() as the key configuration.

source

pub fn with_new_payload(self, payload: P) -> Result<Self, EncryptionError>

This method is a shorthand for EncryptedMessage::with_new_payload_and_key_config, passing &K::default() as the key configuration.

Trait Implementations§

source§

impl<P: Debug + Debug + DeserializeOwned + Serialize, S: Debug + Strategy, K: Debug + KeyConfig> Debug for EncryptedMessage<P, S, K>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, P: Debug + DeserializeOwned + Serialize, S: Strategy, K: KeyConfig> Deserialize<'de> for EncryptedMessage<P, S, K>

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<P: PartialEq + Debug + DeserializeOwned + Serialize, S: PartialEq + Strategy, K: PartialEq + KeyConfig> PartialEq for EncryptedMessage<P, S, K>

source§

fn eq(&self, other: &EncryptedMessage<P, S, K>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<P: Debug + DeserializeOwned + Serialize, S: Strategy, K: KeyConfig> Serialize for EncryptedMessage<P, S, K>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<P: Eq + Debug + DeserializeOwned + Serialize, S: Eq + Strategy, K: Eq + KeyConfig> Eq for EncryptedMessage<P, S, K>

source§

impl<P: Debug + DeserializeOwned + Serialize, S: Strategy, K: KeyConfig> StructuralPartialEq for EncryptedMessage<P, S, K>

Auto Trait Implementations§

§

impl<P, S, K> Freeze for EncryptedMessage<P, S, K>

§

impl<P, S, K> RefUnwindSafe for EncryptedMessage<P, S, K>

§

impl<P, S, K> Send for EncryptedMessage<P, S, K>
where P: Send, S: Send, K: Send,

§

impl<P, S, K> Sync for EncryptedMessage<P, S, K>
where P: Sync, S: Sync, K: Sync,

§

impl<P, S, K> Unpin for EncryptedMessage<P, S, K>
where P: Unpin, S: Unpin, K: Unpin,

§

impl<P, S, K> UnwindSafe for EncryptedMessage<P, S, K>
where P: UnwindSafe, S: UnwindSafe, K: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,