pub struct SbeCursor<'a> { /* private fields */ }Expand description
Zero-copy SBE byte cursor for sequential decoding.
Wraps a byte slice and tracks position, providing typed read methods that automatically advance the cursor.
Implementations§
Source§impl<'a> SbeCursor<'a>
impl<'a> SbeCursor<'a>
Sourcepub const fn new_at(buf: &'a [u8], pos: usize) -> Self
pub const fn new_at(buf: &'a [u8], pos: usize) -> Self
Creates a cursor starting at a specific offset.
Sourcepub fn read_u8(&mut self) -> Result<u8, SbeDecodeError>
pub fn read_u8(&mut self) -> Result<u8, SbeDecodeError>
Reads a u8 and advances by 1 byte.
Sourcepub fn read_i8(&mut self) -> Result<i8, SbeDecodeError>
pub fn read_i8(&mut self) -> Result<i8, SbeDecodeError>
Reads an i8 and advances by 1 byte.
Sourcepub fn read_u16_le(&mut self) -> Result<u16, SbeDecodeError>
pub fn read_u16_le(&mut self) -> Result<u16, SbeDecodeError>
Reads a u16 little-endian and advances by 2 bytes.
Sourcepub fn read_i16_le(&mut self) -> Result<i16, SbeDecodeError>
pub fn read_i16_le(&mut self) -> Result<i16, SbeDecodeError>
Reads an i16 little-endian and advances by 2 bytes.
Sourcepub fn read_u32_le(&mut self) -> Result<u32, SbeDecodeError>
pub fn read_u32_le(&mut self) -> Result<u32, SbeDecodeError>
Reads a u32 little-endian and advances by 4 bytes.
Sourcepub fn read_i32_le(&mut self) -> Result<i32, SbeDecodeError>
pub fn read_i32_le(&mut self) -> Result<i32, SbeDecodeError>
Reads an i32 little-endian and advances by 4 bytes.
Sourcepub fn read_u64_le(&mut self) -> Result<u64, SbeDecodeError>
pub fn read_u64_le(&mut self) -> Result<u64, SbeDecodeError>
Reads a u64 little-endian and advances by 8 bytes.
Sourcepub fn read_i64_le(&mut self) -> Result<i64, SbeDecodeError>
pub fn read_i64_le(&mut self) -> Result<i64, SbeDecodeError>
Reads an i64 little-endian and advances by 8 bytes.
Sourcepub fn read_optional_i64_le(&mut self) -> Result<Option<i64>, SbeDecodeError>
pub fn read_optional_i64_le(&mut self) -> Result<Option<i64>, SbeDecodeError>
Reads an optional i64 where i64::MIN represents None.
Sourcepub fn read_bytes(&mut self, n: usize) -> Result<&'a [u8], SbeDecodeError>
pub fn read_bytes(&mut self, n: usize) -> Result<&'a [u8], SbeDecodeError>
Reads N bytes and advances.
Sourcepub fn read_var_string8(&mut self) -> Result<String, SbeDecodeError>
pub fn read_var_string8(&mut self) -> Result<String, SbeDecodeError>
Reads a varString8 (1-byte length prefix + UTF-8 data).
Returns empty string if length is 0.
Sourcepub fn read_var_string8_ref(&mut self) -> Result<&'a str, SbeDecodeError>
pub fn read_var_string8_ref(&mut self) -> Result<&'a str, SbeDecodeError>
Reads a varString8 as a &str (zero-copy).
Sourcepub fn read_group_header(&mut self) -> Result<(u16, u32), SbeDecodeError>
pub fn read_group_header(&mut self) -> Result<(u16, u32), SbeDecodeError>
Reads group header (u16 block_length + u32 num_in_group).
Returns (block_length, num_in_group).
Sourcepub fn read_group_header_16(&mut self) -> Result<(u16, u16), SbeDecodeError>
pub fn read_group_header_16(&mut self) -> Result<(u16, u16), SbeDecodeError>
Reads compact group header (u16 block_length + u16 num_in_group).
Returns (block_length, num_in_group).
Sourcepub fn read_group<T, F>(
&mut self,
block_length: u16,
num_in_group: u32,
decode_item: F,
) -> Result<Vec<T>, SbeDecodeError>
pub fn read_group<T, F>( &mut self, block_length: u16, num_in_group: u32, decode_item: F, ) -> Result<Vec<T>, SbeDecodeError>
Iterates over a group, calling decode_item for each element.
The decoder function receives a cursor positioned at the start of each item
and should decode the item without advancing past block_length bytes.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for SbeCursor<'a>
impl<'a> RefUnwindSafe for SbeCursor<'a>
impl<'a> Send for SbeCursor<'a>
impl<'a> Sync for SbeCursor<'a>
impl<'a> Unpin for SbeCursor<'a>
impl<'a> UnwindSafe for SbeCursor<'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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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