pub struct Encoder { /* private fields */ }Expand description
Binary encoder with RLE bit packing.
Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn encode<F, R>(f: F) -> R
pub fn encode<F, R>(f: F) -> R
Encode using a thread-local encoder for optimal performance. This avoids allocation overhead by reusing the encoder across calls.
Sourcepub fn push_string(&mut self, val: &str)
pub fn push_string(&mut self, val: &str)
Push a string value with dictionary deduplication.
pub fn push_int(&mut self, val: i64)
pub fn push_bounded_int(&mut self, val: i64, min: i64)
pub fn push_uint(&mut self, val: u64)
pub fn push_float(&mut self, val: f32)
pub fn push_float_quantized(&mut self, val: f32, precision: f32)
pub fn push_boolean(&mut self, val: bool)
pub fn push_enum(&mut self, val: u32, num_bits: u8)
pub fn push_bit_packed_int( &mut self, val: i64, min: i64, max: i64, num_bits: u8, )
pub fn push_string_diff(&mut self, a: &str, b: &str)
pub fn push_int_diff(&mut self, _a: i64, b: i64)
pub fn push_uint_diff(&mut self, _a: u64, b: u64)
pub fn push_bounded_int_diff(&mut self, _a: i64, b: i64, min: i64)
pub fn push_float_diff(&mut self, _a: f32, b: f32)
pub fn push_float_quantized_diff(&mut self, _a: f32, b: f32, precision: f32)
pub fn push_boolean_diff(&mut self, a: bool, b: bool)
pub fn push_enum_diff(&mut self, _a: u32, b: u32, num_bits: u8)
pub fn push_bit_packed_int_diff( &mut self, _a: i64, b: i64, min: i64, max: i64, num_bits: u8, )
pub fn push_object_diff<T, E, F>( &mut self, a: &T, b: &T, equals: E, encode_diff: F, )
pub fn push_field_diff<T, E, F>( &mut self, a: &T, b: &T, equals: E, encode_diff: F, )
Sourcepub fn push_array<T, F>(&mut self, arr: &[T], inner_write: F)
pub fn push_array<T, F>(&mut self, arr: &[T], inner_write: F)
Encode an array by writing length followed by each element.
Sourcepub fn push_array_diff<T, FW, FD, E>(
&mut self,
a: &[T],
b: &[T],
equals: E,
inner_write: FW,
inner_diff: FD,
)
pub fn push_array_diff<T, FW, FD, E>( &mut self, a: &[T], b: &[T], equals: E, inner_write: FW, inner_diff: FD, )
Encode array diff by comparing lengths and elements. Caller handles change bit.
Sourcepub fn push_optional<T, F>(&mut self, opt: &Option<T>, inner_write: F)
pub fn push_optional<T, F>(&mut self, opt: &Option<T>, inner_write: F)
Encode an optional value by writing presence flag followed by value if present.
Sourcepub fn push_optional_diff<T, FW, FD>(
&mut self,
a: &Option<T>,
b: &Option<T>,
inner_write: FW,
inner_diff: FD,
)
pub fn push_optional_diff<T, FW, FD>( &mut self, a: &Option<T>, b: &Option<T>, inner_write: FW, inner_diff: FD, )
Encode optional diff, matching TS/C# format. Optimization: if a was None, we know b must be Some (else unchanged). So skip the present bit in None→Some case.
Sourcepub fn push_record<K, V, FK, FV>(
&mut self,
map: &IndexMap<K, V>,
key_write: FK,
val_write: FV,
)
pub fn push_record<K, V, FK, FV>( &mut self, map: &IndexMap<K, V>, key_write: FK, val_write: FV, )
Encode a record (map) by writing length followed by key-value pairs.
Sourcepub fn push_record_diff<K, V, FK, FV, FVD, E>(
&mut self,
a: &IndexMap<K, V>,
b: &IndexMap<K, V>,
equals: E,
key_write: FK,
val_write: FV,
val_diff: FVD,
)
pub fn push_record_diff<K, V, FK, FV, FVD, E>( &mut self, a: &IndexMap<K, V>, b: &IndexMap<K, V>, equals: E, key_write: FK, val_write: FV, val_diff: FVD, )
Encode record diff, matching TS/C# format. Caller handles change bit.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Encoder
impl RefUnwindSafe for Encoder
impl Send for Encoder
impl Sync for Encoder
impl Unpin for Encoder
impl UnsafeUnpin for Encoder
impl UnwindSafe for Encoder
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