pub struct EncoderBuffer<'a> { /* private fields */ }Expand description
Helper struct for building encoded messages.
Provides a convenient way to track the current write position and manage buffer space.
Implementations§
Source§impl<'a> EncoderBuffer<'a>
impl<'a> EncoderBuffer<'a>
Sourcepub fn new(buffer: &'a mut [u8], offset: usize) -> Self
pub fn new(buffer: &'a mut [u8], offset: usize) -> Self
Creates a new encoder buffer.
§Arguments
buffer- Mutable byte buffer to write tooffset- Starting offset in the buffer
Sourcepub fn buffer_mut(&mut self) -> &mut [u8] ⓘ
pub fn buffer_mut(&mut self) -> &mut [u8] ⓘ
Returns the mutable underlying buffer.
Sourcepub const fn bytes_written(&self) -> usize
pub const fn bytes_written(&self) -> usize
Returns the number of bytes written.
Sourcepub fn set_position(&mut self, pos: usize)
pub fn set_position(&mut self, pos: usize)
Sourcepub fn write_u16_le(&mut self, value: u16)
pub fn write_u16_le(&mut self, value: u16)
Writes a u16 in little-endian at the current position and advances.
Sourcepub fn write_u32_le(&mut self, value: u32)
pub fn write_u32_le(&mut self, value: u32)
Writes a u32 in little-endian at the current position and advances.
Sourcepub fn write_u64_le(&mut self, value: u64)
pub fn write_u64_le(&mut self, value: u64)
Writes a u64 in little-endian at the current position and advances.
Sourcepub fn write_bytes(&mut self, data: &[u8])
pub fn write_bytes(&mut self, data: &[u8])
Writes bytes at the current position and advances.
Sourcepub fn write_zeros(&mut self, count: usize)
pub fn write_zeros(&mut self, count: usize)
Writes zeros at the current position and advances.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for EncoderBuffer<'a>
impl<'a> RefUnwindSafe for EncoderBuffer<'a>
impl<'a> Send for EncoderBuffer<'a>
impl<'a> Sync for EncoderBuffer<'a>
impl<'a> Unpin for EncoderBuffer<'a>
impl<'a> !UnwindSafe for EncoderBuffer<'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