Skip to main content

Decoder

Struct Decoder 

Source
pub struct Decoder<'a> { /* private fields */ }
Expand description

Binary decoder with string dictionary and RLE bit unpacking.

Implementations§

Source§

impl<'a> Decoder<'a>

Source

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

Source

pub fn decode<F, R>(buf: &[u8], f: F) -> R
where F: FnOnce(&mut Decoder<'_>) -> R,

Decode using a thread-local decoder for optimal performance. This avoids allocation overhead by reusing the dictionary Vec across calls.

Source

pub fn next_string(&mut self) -> String

Source

pub fn next_int(&mut self) -> i64

Source

pub fn next_uint(&mut self) -> u64

Source

pub fn next_bounded_int(&mut self, min: i64) -> i64

Source

pub fn next_float(&mut self) -> f32

Source

pub fn next_float_quantized(&mut self, precision: f32) -> f32

Source

pub fn next_boolean(&mut self) -> bool

Source

pub fn next_enum(&mut self, num_bits: u8) -> u32

Source

pub fn next_string_diff(&mut self, a: &str) -> String

Source

pub fn next_int_diff(&mut self, _a: i64) -> i64

Source

pub fn next_uint_diff(&mut self, _a: u64) -> u64

Source

pub fn next_bounded_int_diff(&mut self, _a: i64, min: i64) -> i64

Source

pub fn next_float_diff(&mut self, _a: f32) -> f32

Source

pub fn next_float_quantized_diff(&mut self, _a: f32, precision: f32) -> f32

Source

pub fn next_boolean_diff(&mut self, a: bool) -> bool

Source

pub fn next_enum_diff(&mut self, _a: u32, num_bits: u8) -> u32

Source

pub fn next_object_diff<T, F>(&mut self, a: &T, decode_diff: F) -> T
where T: Clone, F: FnOnce(&mut Self) -> T,

Source

pub fn next_field_diff<T, F>(&mut self, a: &T, decode_diff: F) -> T
where T: Clone, F: FnOnce(&mut Self, &T) -> T,

Source

pub fn next_array<T, F>(&mut self, inner_read: F) -> Vec<T>
where F: FnMut(&mut Self) -> T,

Decode an array by reading length followed by each element.

Source

pub fn next_array_diff<T, F, FD>( &mut self, a: &[T], inner_read: F, inner_diff: FD, ) -> Vec<T>
where T: Clone, F: FnMut(&mut Self) -> T, FD: FnMut(&mut Self, &T) -> T,

Decode array diff, using sparse format with index-based updates. Caller handles change bit.

Source

pub fn next_optional<T, F>(&mut self, inner_read: F) -> Option<T>
where F: FnMut(&mut Self) -> T,

Source

pub fn next_optional_diff<T, F, FD>( &mut self, a: &Option<T>, inner_read: F, inner_diff: FD, ) -> Option<T>
where T: Clone, F: FnMut(&mut Self) -> T, FD: FnMut(&mut Self, &T) -> T,

Decode optional diff, matching TS/C# format. Optimization: if a was None, we know b must be Some (else unchanged). So no present bit in None→Some case.

Source

pub fn next_record<K, V, FK, FV>( &mut self, key_read: FK, val_read: FV, ) -> IndexMap<K, V>
where K: Eq + Hash, FK: FnMut(&mut Self) -> K, FV: FnMut(&mut Self) -> V,

Decode a record (map) by reading length followed by key-value pairs.

Source

pub fn next_record_diff<K, V, FK, FV, FVD>( &mut self, a: &IndexMap<K, V>, key_read: FK, val_read: FV, val_diff: FVD, ) -> IndexMap<K, V>
where K: Clone + Eq + Hash, V: Clone, FK: FnMut(&mut Self) -> K, FV: FnMut(&mut Self) -> V, FVD: FnMut(&mut Self, &V) -> V,

Decode record diff, matching TS/C# format. Caller handles change bit. Format: if a.len > 0: deletions, updates; then additions

Auto Trait Implementations§

§

impl<'a> Freeze for Decoder<'a>

§

impl<'a> RefUnwindSafe for Decoder<'a>

§

impl<'a> Send for Decoder<'a>

§

impl<'a> Sync for Decoder<'a>

§

impl<'a> Unpin for Decoder<'a>

§

impl<'a> UnsafeUnpin for Decoder<'a>

§

impl<'a> UnwindSafe for Decoder<'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, 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.