pub struct Message { /* private fields */ }Expand description
A multi-part message, comprising a message body and a list of parts. Messages only contain references to underlying byte buffers and are cheaply cloned.
Implementations§
Source§impl Message
impl Message
Sourcepub fn from_body_and_parts(body: Part, parts: Vec<Part>) -> Self
pub fn from_body_and_parts(body: Part, parts: Vec<Part>) -> Self
Returns a new message with the given body and parts.
Sourcepub fn num_parts(&self) -> usize
pub fn num_parts(&self) -> usize
Returns the total number of parts (excluding the body) in the message.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether the message is empty. It is always false, since the body is always defined.
Sourcepub fn into_inner(self) -> (Part, Vec<Part>)
pub fn into_inner(self) -> (Part, Vec<Part>)
Convert this message into its constituent components.
Sourcepub fn frame_len(&self) -> usize
pub fn frame_len(&self) -> usize
Returns the total size (in bytes) of the message when it is framed.
Sourcepub fn framed(self) -> Frame
pub fn framed(self) -> Frame
Efficiently frames a message containing the body and all of its parts using a simple frame-length encoding:
+--------------------+-------------------+--------------------+-------------------+ ... +
| body_len (u64 BE) | body bytes | part1_len (u64 BE) | part1 bytes | |
+--------------------+-------------------+--------------------+-------------------+ +
repeat
for
each partSourcepub fn from_framed(buf: Bytes) -> Result<Self, Error>
pub fn from_framed(buf: Bytes) -> Result<Self, Error>
Reassembles a message from a framed encoding.
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
impl Eq for Message
impl 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