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-endianBE
or little-endianLE
).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§
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>,
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.