pub struct Frame<'a> { /* private fields */ }Expand description
A frame extracted from an input byte slice.
The payload borrow lives as long as the input slice, so framers never
copy data. consumed tells the caller how many bytes from the input the
frame occupied in total, including any header or delimiter bytes.
§Example
use wire_codec::framing::Frame;
let input = b"\x03abcrest";
let frame = Frame::new(&input[1..4], 4);
assert_eq!(frame.payload(), b"abc");
assert_eq!(frame.consumed(), 4);Implementations§
Source§impl<'a> Frame<'a>
impl<'a> Frame<'a>
Sourcepub const fn new(payload: &'a [u8], consumed: usize) -> Self
pub const fn new(payload: &'a [u8], consumed: usize) -> Self
Construct a frame from its payload and total consumed-byte count.
consumed must be at least payload.len() and, for any framer used
in a while let Some(frame) loop, greater than zero: a framer that
reports zero consumed bytes would hand back the same frame forever.
Framers in this crate uphold both invariants. The first one is checked
with a debug_assert!.
Trait Implementations§
impl<'a> Copy for Frame<'a>
impl<'a> Eq for Frame<'a>
impl<'a> StructuralPartialEq for Frame<'a>
Auto Trait Implementations§
impl<'a> Freeze for Frame<'a>
impl<'a> RefUnwindSafe for Frame<'a>
impl<'a> Send for Frame<'a>
impl<'a> Sync for Frame<'a>
impl<'a> Unpin for Frame<'a>
impl<'a> UnsafeUnpin for Frame<'a>
impl<'a> UnwindSafe for Frame<'a>
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