Struct serde_encrypt::EncryptedMessage
source · [−]pub struct EncryptedMessage { /* private fields */ }
Expand description
Encrypted message structure.
This struct is serialized into Vec<u8>
(and deserialized from Vec<u8>
).
In order to send an EncryptedMessage to a remote receiver, use let bin = encrypted_message.serialize();
.
Then, the receiver should deserialize it by let encrypted_message = EncryptedMessage::deserialize(bin);
.
This struct includes Nonce, which is internally used when a receiver decrypt the encrypted message.
Implementations
sourceimpl EncryptedMessage
impl EncryptedMessage
sourcepub fn serialize(self) -> Vec<u8, Global>
pub fn serialize(self) -> Vec<u8, Global>
Serialize this encrypted message into binary in order to send it to a remote receiver.
sourcepub fn deserialize(
serialized_encrypted_message: Vec<u8, Global>
) -> Result<EncryptedMessage, Error>
pub fn deserialize(
serialized_encrypted_message: Vec<u8, Global>
) -> Result<EncryptedMessage, Error>
Deserializer function for a receiver.
Failures
- DeserializationError when:
- binary data does not have nonce.
sourcepub fn nonce(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn nonce(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Ref to XChaCha20 nonce (192-bit / 24-byte) used to create this encrypted message.
Trait Implementations
sourceimpl Clone for EncryptedMessage
impl Clone for EncryptedMessage
sourcefn clone(&self) -> EncryptedMessage
fn clone(&self) -> EncryptedMessage
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for EncryptedMessage
impl Debug for EncryptedMessage
sourceimpl PartialEq<EncryptedMessage> for EncryptedMessage
impl PartialEq<EncryptedMessage> for EncryptedMessage
sourcefn eq(&self, other: &EncryptedMessage) -> bool
fn eq(&self, other: &EncryptedMessage) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &EncryptedMessage) -> bool
fn ne(&self, other: &EncryptedMessage) -> bool
This method tests for !=
.
impl Eq for EncryptedMessage
impl StructuralEq for EncryptedMessage
impl StructuralPartialEq for EncryptedMessage
Auto Trait Implementations
impl RefUnwindSafe for EncryptedMessage
impl Send for EncryptedMessage
impl Sync for EncryptedMessage
impl Unpin for EncryptedMessage
impl UnwindSafe for EncryptedMessage
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more