pub struct SbeWriter<'a> { /* private fields */ }Expand description
Pre-sized SBE byte writer for sequential encoding.
Wraps a mutable [MaybeUninit<u8>] slice and tracks position, providing
typed write methods that automatically advance the cursor. The caller is
responsible for sizing the backing buffer to hold the full encoded
message; writing past the end panics.
The writer uses MaybeUninit<u8> to avoid requiring the target buffer to
be zero-initialized. Callers wrapping an already-initialized &mut [u8]
can use SbeWriter::new; callers writing into uninit capacity (e.g.
Vec::spare_capacity_mut) can use SbeWriter::new_uninit.
Implementations§
Source§impl<'a> SbeWriter<'a>
impl<'a> SbeWriter<'a>
Sourcepub fn new_uninit(buf: &'a mut [MaybeUninit<u8>]) -> Self
pub fn new_uninit(buf: &'a mut [MaybeUninit<u8>]) -> Self
Creates a new writer over an uninitialized byte buffer.
Sourcepub fn write_u16_le(&mut self, value: u16)
pub fn write_u16_le(&mut self, value: u16)
Writes a u16 little-endian and advances by 2 bytes.
Sourcepub fn write_i16_le(&mut self, value: i16)
pub fn write_i16_le(&mut self, value: i16)
Writes an i16 little-endian and advances by 2 bytes.
Sourcepub fn write_u32_le(&mut self, value: u32)
pub fn write_u32_le(&mut self, value: u32)
Writes a u32 little-endian and advances by 4 bytes.
Sourcepub fn write_i32_le(&mut self, value: i32)
pub fn write_i32_le(&mut self, value: i32)
Writes an i32 little-endian and advances by 4 bytes.
Sourcepub fn write_u64_le(&mut self, value: u64)
pub fn write_u64_le(&mut self, value: u64)
Writes a u64 little-endian and advances by 8 bytes.
Sourcepub fn write_i64_le(&mut self, value: i64)
pub fn write_i64_le(&mut self, value: i64)
Writes an i64 little-endian and advances by 8 bytes.
Sourcepub fn write_u128_le(&mut self, value: u128)
pub fn write_u128_le(&mut self, value: u128)
Writes a u128 little-endian and advances by 16 bytes.
Sourcepub fn write_i128_le(&mut self, value: i128)
pub fn write_i128_le(&mut self, value: i128)
Writes an i128 little-endian and advances by 16 bytes.
Sourcepub fn write_bytes(&mut self, bytes: &[u8])
pub fn write_bytes(&mut self, bytes: &[u8])
Writes a slice of bytes and advances by its length.