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.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for SbeWriter<'a>
impl<'a> RefUnwindSafe for SbeWriter<'a>
impl<'a> Send for SbeWriter<'a>
impl<'a> Sync for SbeWriter<'a>
impl<'a> Unpin for SbeWriter<'a>
impl<'a> UnsafeUnpin for SbeWriter<'a>
impl<'a> !UnwindSafe for SbeWriter<'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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more