[−][src]Struct encon::WithIntent
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]
fn clone(&self) -> WithIntent
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for WithIntent
[src]
impl Deref for WithIntent
[src]
type Target = Encryptable
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl DerefMut for WithIntent
[src]
impl<'de> Deserialize<'de> for WithIntent
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl From<Encryptable> for WithIntent
[src]
fn from(inner: Encryptable) -> Self
[src]
impl Serialize for WithIntent
[src]
Auto Trait Implementations
impl RefUnwindSafe for WithIntent
impl Send for WithIntent
impl Sync for WithIntent
impl Unpin for WithIntent
impl UnwindSafe for WithIntent
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,