Struct wire_framed_core::Message
source · pub struct Message { /* private fields */ }Expand description
A message with frames.
Frame
A frame consists of the length of the blob and the blob itself.
| blob length | blob |
Message
A message consists of (potentially) many frames. After a frame, a special byte exists to denote if the message has more frames to read. The byte contains 0 if it has no more frames and 1 if it has.
| frame | frame end byte |
Implementations§
source§impl Message
impl Message
sourcepub fn from_frames(frames: impl Into<VecDeque<Bytes>>) -> Self
pub fn from_frames(frames: impl Into<VecDeque<Bytes>>) -> Self
Constructs a Message from an iterator of [Frame]s.
sourcepub fn builder() -> MessageBuilder
pub fn builder() -> MessageBuilder
Constructs a MessageBuilder.
sourcepub fn extend(&mut self, frames: impl IntoIterator<Item = Bytes>)
pub fn extend(&mut self, frames: impl IntoIterator<Item = Bytes>)
Extends a collection with the contents of an iterator.
sourcepub fn push_message(&mut self, msg: Message)
pub fn push_message(&mut self, msg: Message)
Push a message into the message.
sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
Returns the number of frames in the message.
sourcepub fn byte_count(&self) -> usize
pub fn byte_count(&self) -> usize
Returns the total length of the message in bytes.
sourcepub fn as_deque(&self) -> &VecDeque<Bytes>
pub fn as_deque(&self) -> &VecDeque<Bytes>
Returns the message as an immutable VecDeque of frames.
sourcepub fn as_deque_mut(&mut self) -> &mut VecDeque<Bytes>
pub fn as_deque_mut(&mut self) -> &mut VecDeque<Bytes>
Returns the message as a mutable VecDeque of frames.
Trait Implementations§
source§impl Encoder<Message> for MessageCodec
impl Encoder<Message> for MessageCodec
source§impl IntoMessage for Message
impl IntoMessage for Message
source§fn extend_message(&self, msg: &mut Message)
fn extend_message(&self, msg: &mut Message)
Extend a
Message with the contents of Self.source§fn into_message(&self) -> Message
fn into_message(&self) -> Message
Converts
Self into an owned Message.fn into_bytes(&self) -> Bytes
source§impl PartialEq<Message> for Message
impl PartialEq<Message> for Message
impl Eq for Message
impl StructuralEq for Message
impl StructuralPartialEq for Message
Auto Trait Implementations§
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