pub struct Message {
pub header: Header,
pub payload: Vec<u8>,
}
Fields§
§header: Header
§payload: Vec<u8>
Implementations§
source§impl Message
impl Message
sourcepub fn set_header<T: Into<u8>, U: Into<[u8; 32]>, V: RngCore + CryptoRng>(
self,
msgtype: T,
pubkey: U,
csprng: &mut V
) -> Result<Message, RtjError>
pub fn set_header<T: Into<u8>, U: Into<[u8; 32]>, V: RngCore + CryptoRng>( self, msgtype: T, pubkey: U, csprng: &mut V ) -> Result<Message, RtjError>
Sets the Message
header field
This method can only be called after Message::set_payload
as the header itself contains the size of the payload in bytes.
Public key bytes to be sent in the Header
must be the public
part of the sender’s SecretKey
.
sourcepub fn encrypt(
self,
public: PublicKey,
secret: SecretKey
) -> Result<Message, RtjError>
pub fn encrypt( self, public: PublicKey, secret: SecretKey ) -> Result<Message, RtjError>
Encrypts and resets the Message
payload field using the specified PublicKey
of the recipient and SecretKey
of the sender.
The Header
is updated to:
- Reflect the new payload length
- Set the encrypted flag
Payload is encrypted for the given pubkey.
Encryption is done using crypto_box
in its default configuration.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 PartialEq for Message
impl PartialEq for Message
source§impl PartialOrd for Message
impl PartialOrd for Message
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl StructuralPartialEq for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
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