Skip to main content

SbeWriter

Struct SbeWriter 

Source
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>

Source

pub fn new(buf: &'a mut [u8]) -> Self

Creates a new writer over an initialized byte buffer.

Source

pub fn new_uninit(buf: &'a mut [MaybeUninit<u8>]) -> Self

Creates a new writer over an uninitialized byte buffer.

Source

pub const fn pos(&self) -> usize

Current write position in the buffer.

Source

pub const fn len(&self) -> usize

Total buffer length.

Source

pub const fn is_empty(&self) -> bool

Whether the buffer is empty.

Source

pub fn write_u8(&mut self, value: u8)

Writes a single byte and advances by 1.

Source

pub fn write_i8(&mut self, value: i8)

Writes a signed single byte and advances by 1.

Source

pub fn write_u16_le(&mut self, value: u16)

Writes a u16 little-endian and advances by 2 bytes.

Source

pub fn write_i16_le(&mut self, value: i16)

Writes an i16 little-endian and advances by 2 bytes.

Source

pub fn write_u32_le(&mut self, value: u32)

Writes a u32 little-endian and advances by 4 bytes.

Source

pub fn write_i32_le(&mut self, value: i32)

Writes an i32 little-endian and advances by 4 bytes.

Source

pub fn write_u64_le(&mut self, value: u64)

Writes a u64 little-endian and advances by 8 bytes.

Source

pub fn write_i64_le(&mut self, value: i64)

Writes an i64 little-endian and advances by 8 bytes.

Source

pub fn write_u128_le(&mut self, value: u128)

Writes a u128 little-endian and advances by 16 bytes.

Source

pub fn write_i128_le(&mut self, value: i128)

Writes an i128 little-endian and advances by 16 bytes.

Source

pub fn write_bytes(&mut self, bytes: &[u8])

Writes a slice of bytes and advances by its length.

Trait Implementations§

Source§

impl<'a> Debug for SbeWriter<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

§

impl<T> Ungil for T
where T: Send,