Struct aldrin_core::message::Packetizer
source · 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.
pub fn next_message(&mut self) -> Option<BytesMut>
Trait Implementations§
source§impl Debug for Packetizer
impl Debug for Packetizer
Auto Trait Implementations§
impl RefUnwindSafe for Packetizer
impl Send for Packetizer
impl Sync for Packetizer
impl Unpin for Packetizer
impl UnwindSafe for Packetizer
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