Struct EncryptedMessage

Source
pub struct EncryptedMessage<P: Debug + DeserializeOwned + Serialize, C: Config> { /* 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, C: Config> EncryptedMessage<P, C>

Source

pub fn encrypt_with_config( payload: P, config: &C, ) -> Result<Self, EncryptionError>

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

§Errors
Source

pub fn decrypt_with_config(&self, config: &C) -> Result<P, DecryptionError>

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

§Errors
Source§

impl<P: Debug + DeserializeOwned + Serialize, C: Config + Default> EncryptedMessage<P, C>

Source

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

This method is a shorthand for EncryptedMessage::encrypt_with_config, passing &C::default() as the configuration.

Source

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

This method is a shorthand for EncryptedMessage::decrypt_with_config, passing &C::default() as the configuration.

Trait Implementations§

Source§

impl<P: Debug + Debug + DeserializeOwned + Serialize, C: Debug + Config> Debug for EncryptedMessage<P, C>

Source§

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

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

impl<'de, P: Debug + DeserializeOwned + Serialize, C: Config> Deserialize<'de> for EncryptedMessage<P, C>

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, C: PartialEq + Config> PartialEq for EncryptedMessage<P, C>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<P: Debug + DeserializeOwned + Serialize, C: Config> Serialize for EncryptedMessage<P, C>

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, C: Eq + Config> Eq for EncryptedMessage<P, C>

Source§

impl<P: Debug + DeserializeOwned + Serialize, C: Config> StructuralPartialEq for EncryptedMessage<P, C>

Auto Trait Implementations§

§

impl<P, C> Freeze for EncryptedMessage<P, C>

§

impl<P, C> RefUnwindSafe for EncryptedMessage<P, C>

§

impl<P, C> Send for EncryptedMessage<P, C>
where P: Send, C: Send,

§

impl<P, C> Sync for EncryptedMessage<P, C>
where P: Sync, C: Sync,

§

impl<P, C> Unpin for EncryptedMessage<P, C>
where P: Unpin, C: Unpin,

§

impl<P, C> UnwindSafe for EncryptedMessage<P, C>
where P: UnwindSafe, C: 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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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>,