[][src]Struct encon::WithIntent

pub struct WithIntent { /* fields omitted */ }

A wrapper around Encryptable that also has an intent flag, indicating if we'd like it to be outputted as encrypted or plain.

Derefs into Encryptable.

Implementations

impl WithIntent[src]

pub fn intent(&self) -> EncryptableKind[src]

Get the current intent

pub fn intent_mut(&mut self) -> &mut EncryptableKind[src]

Get a mutable reference to the current intent

pub fn intend_encrypted(&mut self) -> &mut Self[src]

Set the intent to EncryptableKind::Encrypted without changing the underlying Encryptable.

pub fn intend_plain(&mut self) -> &mut Self[src]

Set the intent to EncryptableKind::Plain without changing the underlying Encryptable.

pub fn apply_intent(&mut self, password: &Password) -> Result<(), EnconError>[src]

Set the intent to EncryptableKind::Plain without changing the underlying Encryptable.

pub fn to_decrypted(&self, password: &Password) -> Result<Self, DecryptError>[src]

Like Encryptable::to_decrypted but preserving the intent.

pub fn to_encrypted(&self, password: &Password) -> Result<Self, EncryptError>[src]

Like Encryptable::to_encrypted but preserving the intent.

Methods from Deref<Target = Encryptable>

pub fn kind(&self) -> EncryptableKind[src]

Returns the variant kind.

pub fn is_encrypted(&self) -> bool[src]

pub fn as_encrypted(&self) -> Option<&[u8]>[src]

If this is the encrypted variant, returns a the encrypted blob.

pub fn as_plain(&self) -> Option<&Value>[src]

If this is the plain variant, returns the serde_json Value.

pub fn to_encrypted(&self, password: &Password) -> Result<Self, EncryptError>[src]

If not already encrypted, this will return an encrypted copy of the Encryptable.

See Password::encrypt for details.

pub fn to_decrypted(&self, password: &Password) -> Result<Self, DecryptError>[src]

If not already in the plain variant, this will return a decrypted/plain copy of the Encryptable. Will return an error if the password is invalid, or the encrypted blob is invalid.

See Password::decrypt for details.

Trait Implementations

impl Clone for WithIntent[src]

impl Debug for WithIntent[src]

impl Deref for WithIntent[src]

type Target = Encryptable

The resulting type after dereferencing.

impl DerefMut for WithIntent[src]

impl<'de> Deserialize<'de> for WithIntent[src]

impl From<Encryptable> for WithIntent[src]

impl Serialize for WithIntent[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.