pub struct Encoder<M> where
    M: Model
{ /* private fields */ }
Expand description

An arithmetic encoder

An arithmetic decoder converts a stream of symbols into a stream of bits, using a predictive Model.

Implementations

Construct a new Encoder.

The ‘precision’ of the encoder is maximised, based on the number of bits needed to represent the Model::denominator. ‘precision’ bits is equal to BitStore::BITS - Model::denominator bits. If you need to set the precision manually, use Encoder::with_precision.

Panics

The calculation of the number of bits used for ‘precision’ is subject to the following constraints:

If these constraints cannot be satisfied this method will panic in debug builds

Construct a new Encoder with a custom precision.

Panics

The calculation of the number of bits used for ‘precision’ is subject to the following constraints:

If these constraints cannot be satisfied this method will panic in debug builds

Encode a stream of symbols into the provided output.

This method will encode all the symbols in the iterator, followed by EOF (None), and then call Encoder::flush.

Errors

This method can fail if the underlying BitWrite cannot be written to.

Encode a symbol into the provided output.

When you finish encoding symbols, you must manually encode an EOF symbol by calling Encoder::encode with None.

The internal buffer must be manually flushed using Encoder::flush.

Errors

This method can fail if the underlying BitWrite cannot be written to.

Flush any pending bits from the buffer

This method must be called when you finish writing symbols to a stream of bits. This is called automatically when you use Encoder::encode_all.

Errors

This method can fail if the underlying BitWrite cannot be written to.

Reuse the internal state of the Encoder with a new model.

Allows for chaining multiple sequences of symbols into a single stream of bits

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.