pub struct Decoder<'a> { /* private fields */ }Expand description
Binary decoder with string dictionary and RLE bit unpacking.
Implementations§
Source§impl<'a> Decoder<'a>
impl<'a> Decoder<'a>
pub fn new(buf: &'a [u8]) -> Self
Sourcepub fn decode<F, R>(buf: &[u8], f: F) -> R
pub fn decode<F, R>(buf: &[u8], f: F) -> R
Decode using a thread-local decoder for optimal performance. This avoids allocation overhead by reusing the dictionary Vec across calls.
pub fn next_string(&mut self) -> String
pub fn next_int(&mut self) -> i64
pub fn next_uint(&mut self) -> u64
pub fn next_bounded_int(&mut self, min: i64) -> i64
pub fn next_float(&mut self) -> f32
pub fn next_float_quantized(&mut self, precision: f32) -> f32
pub fn next_boolean(&mut self) -> bool
pub fn next_enum(&mut self, num_bits: u8) -> u32
pub fn next_string_diff(&mut self, a: &str) -> String
pub fn next_int_diff(&mut self, _a: i64) -> i64
pub fn next_uint_diff(&mut self, _a: u64) -> u64
pub fn next_bounded_int_diff(&mut self, _a: i64, min: i64) -> i64
pub fn next_float_diff(&mut self, _a: f32) -> f32
pub fn next_float_quantized_diff(&mut self, _a: f32, precision: f32) -> f32
pub fn next_boolean_diff(&mut self, a: bool) -> bool
pub fn next_enum_diff(&mut self, _a: u32, num_bits: u8) -> u32
pub fn next_object_diff<T, F>(&mut self, a: &T, decode_diff: F) -> T
pub fn next_field_diff<T, F>(&mut self, a: &T, decode_diff: F) -> T
Sourcepub fn next_array<T, F>(&mut self, inner_read: F) -> Vec<T>where
F: FnMut(&mut Self) -> T,
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.
Sourcepub fn next_array_diff<T, F, FD>(
&mut self,
a: &[T],
inner_read: F,
inner_diff: FD,
) -> Vec<T>
pub fn next_array_diff<T, F, FD>( &mut self, a: &[T], inner_read: F, inner_diff: FD, ) -> Vec<T>
Decode array diff, using sparse format with index-based updates. Caller handles change bit.
pub fn next_optional<T, F>(&mut self, inner_read: F) -> Option<T>where
F: FnMut(&mut Self) -> T,
Sourcepub fn next_optional_diff<T, F, FD>(
&mut self,
a: &Option<T>,
inner_read: F,
inner_diff: FD,
) -> Option<T>
pub fn next_optional_diff<T, F, FD>( &mut self, a: &Option<T>, inner_read: F, inner_diff: FD, ) -> Option<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.
Sourcepub fn next_record<K, V, FK, FV>(
&mut self,
key_read: FK,
val_read: FV,
) -> IndexMap<K, V>
pub fn next_record<K, V, FK, FV>( &mut self, key_read: FK, val_read: FV, ) -> IndexMap<K, V>
Decode a record (map) by reading length followed by key-value pairs.
Sourcepub 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>
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>
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> 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
Mutably borrows from an owned value. Read more