Trait Codec

Source
pub trait Codec<E: Endianness, W: BitWrite<E>> {
    type Params;

    // Required methods
    fn encode(
        writer: &mut W,
        value: u64,
        params: Self::Params,
    ) -> Result<usize, Box<dyn Error>>;
    fn decode<R2>(
        reader: &mut R2,
        params: Self::Params,
    ) -> Result<u64, Box<dyn Error>>
       where R2: for<'a> GammaRead<E> + DeltaRead<E> + ExpGolombRead<E> + ZetaRead<E> + RiceRead<E> + ZetaReadParam<E> + DeltaReadParam<E> + GammaReadParam<E> + MinimalBinaryRead<E>;
}
Expand description

Trait for encoding and decoding values using a variable-length code.

The trait is generic over an endianness type E and abstracts over writing/reading bit-level representations.

§Type Parameters

  • E: Endianness marker (e.g. big-endian BE or little-endian LE).
  • W: A writer capable of writing bits/words in the specified codec.

§Associated Types

  • Params: The type of extra parameters needed for the codec. For many codecs this is (), but some require additional runtime parameters.

Required Associated Types§

Required Methods§

Source

fn encode( writer: &mut W, value: u64, params: Self::Params, ) -> Result<usize, Box<dyn Error>>

Source

fn decode<R2>( reader: &mut R2, params: Self::Params, ) -> Result<u64, Box<dyn Error>>
where R2: for<'a> GammaRead<E> + DeltaRead<E> + ExpGolombRead<E> + ZetaRead<E> + RiceRead<E> + ZetaReadParam<E> + DeltaReadParam<E> + GammaReadParam<E> + MinimalBinaryRead<E>,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<E: Endianness, W: DeltaWrite<E>> Codec<E, W> for DeltaCodec

Source§

impl<E: Endianness, W: ExpGolombWrite<E>> Codec<E, W> for ExpGolombCodec

Source§

impl<E: Endianness, W: GammaWrite<E>> Codec<E, W> for GammaCodec

Source§

impl<E: Endianness, W: GammaWriteParam<E>, const USE_TABLE: bool> Codec<E, W> for ParamGammaCodec<USE_TABLE>

Source§

impl<E: Endianness, W: MinimalBinaryWrite<E>> Codec<E, W> for MinimalBinaryCodec

Source§

impl<E: Endianness, W: RiceWrite<E>> Codec<E, W> for RiceCodec

Source§

impl<E: Endianness, W: ZetaWrite<E>> Codec<E, W> for ZetaCodec

Source§

impl<E: Endianness, W: ZetaWriteParam<E>, const USE_TABLE: bool> Codec<E, W> for ParamZetaCodec<USE_TABLE>

Source§

impl<E: Endianness, const USE_DELTA_TABLE: bool, const USE_GAMMA_TABLE: bool, W: DeltaWriteParam<E>> Codec<E, W> for ParamDeltaCodec<USE_DELTA_TABLE, USE_GAMMA_TABLE>