pub enum EncryptedOr<T> {
Encrypted(Vec<u8>),
Plain(T),
}
Expand description
A generic enum representing either encrypted or plain data.
The EncryptedOr
enum is used to differentiate between encrypted data and unencrypted (plain) data.
It allows to store either type of data in the same structure while providing methods to safely access
or mutate the contents, depending on whether the data is encrypted or not.
Variants§
Encrypted(Vec<u8>)
Contains encrypted data as a vector of bytes.
Plain(T)
Contains plain, unencrypted data of type T
.
Implementations§
Source§impl<T> EncryptedOr<T>
impl<T> EncryptedOr<T>
Sourcepub fn is_encrypted(&self) -> bool
pub fn is_encrypted(&self) -> bool
Returns true
if the data is encrypted.
This method allows checking if the current instance of EncryptedOr
contains encrypted data.
Sourcepub fn is_plain(&self) -> bool
pub fn is_plain(&self) -> bool
Returns true
if the data is plain.
This method allows checking if the current instance of EncryptedOr
contains plain (unencrypted) data.
pub fn unwrap(self) -> T
Trait Implementations§
Source§impl<T> AsMut<[u8]> for EncryptedOr<T>
impl<T> AsMut<[u8]> for EncryptedOr<T>
Source§impl<T> AsMut<T> for EncryptedOr<T>
impl<T> AsMut<T> for EncryptedOr<T>
Source§impl<T> AsRef<[u8]> for EncryptedOr<T>
impl<T> AsRef<[u8]> for EncryptedOr<T>
Source§impl<T> AsRef<T> for EncryptedOr<T>
impl<T> AsRef<T> for EncryptedOr<T>
Source§impl<T: Debug> Debug for EncryptedOr<T>
impl<T: Debug> Debug for EncryptedOr<T>
Source§impl<T: FromStream> FromStream for EncryptedOr<T>
impl<T: FromStream> FromStream for EncryptedOr<T>
Source§impl<T: ToStream> ToStream for EncryptedOr<T>
impl<T: ToStream> ToStream for EncryptedOr<T>
Auto Trait Implementations§
impl<T> Freeze for EncryptedOr<T>where
T: Freeze,
impl<T> RefUnwindSafe for EncryptedOr<T>where
T: RefUnwindSafe,
impl<T> Send for EncryptedOr<T>where
T: Send,
impl<T> Sync for EncryptedOr<T>where
T: Sync,
impl<T> Unpin for EncryptedOr<T>where
T: Unpin,
impl<T> UnwindSafe for EncryptedOr<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self
into the result. Lower case
letters are used (e.g. f9b4ca
)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self
into the result. Upper case
letters are used (e.g. F9B4CA
)