pub struct Packetizer { /* private fields */ }Expand description
Splits a continuous stream of bytes into individual messages.
Implementations§
Source§impl Packetizer
impl Packetizer
pub fn new() -> Self
pub fn extend_from_slice(&mut self, bytes: &[u8])
Sourcepub fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<u8>]
pub fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<u8>]
Returns a slice of uninitialized bytes at the end of the internal buffer.
This function, together with bytes_written, make it possible to
fill the packetizer without an intermediate buffer.
The slice returned by this function is guaranteed to be non-empty.
Sourcepub unsafe fn bytes_written(&mut self, len: usize)
pub unsafe fn bytes_written(&mut self, len: usize)
Asserts that the next len bytes have been initialized.
§Safety
You must ensure that prior to calling this function, at least len bytes of the slice
returned by spare_capacity_mut have been initialized.