DedupeDecoder

Struct DedupeDecoder 

Source
pub struct DedupeDecoder { /* private fields */ }
Expand description

Companion to DedupeEncoder that reconstructs repeated values from IDs.

Implementations§

Source§

impl DedupeDecoder

Source

pub fn new() -> Self

Creates a new empty DedupeDecoder.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates a new DedupeDecoder with the specified capacity.

The decoder will be able to hold at least capacity cached values without reallocating. Creates a decoder with a pre‑allocated value table of capacity.

Source

pub fn clear(&mut self)

Clears cached values.

Source

pub fn len(&self) -> usize

Returns the number of cached values.

Source

pub fn is_empty(&self) -> bool

Returns true if the cache is empty.

Source

pub fn decode<T: Pack + Clone + Hash + Eq + Send + Sync + 'static>( &mut self, reader: &mut impl Read, ) -> Result<T>

Decodes a value with deduplication.

If the ID is 0, a new value is decoded and stored in the table. Otherwise, the value is retrieved from the table using the given ID.

§Arguments
  • reader - The reader from which the encoded data will be read.
§Returns

The decoded value. Decodes a value with deduplication support.

If the next ID is 0, a fresh value is decoded, stored, and returned. Otherwise, the referenced value is loaded from the cache.

Trait Implementations§

Source§

impl Default for DedupeDecoder

Source§

fn default() -> DedupeDecoder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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