pub struct RangeEncoder<Word, State, Backend = Vec<Word>>where
    Word: BitArray,
    State: BitArray,
    Backend: WriteWords<Word>,
{ /* private fields */ }

Implementations§

Creates an empty encoder for range coding.

Assumes that the backend is in a state where the encoder can start writing as if it was an empty backend. If there’s already some compressed data on backend, then this method will just concatanate the new sequence of Words to the existing sequence of Words without gluing them together. This is likely not what you want since you won’t be able to decode the data in one go (however, it is Ok to concatenate arbitrary data to the output of a RangeEncoder; it won’t invalidate the existing data).

If you need an entropy coder that can be interrupted and serialized/deserialized (i.e., an encoder that can encode some symbols, return the compressed bit string as a sequence of Words, load the Words back in at a later point and then encode some more symbols), then consider using an AnsCoder.

TODO: rename to with_write_backend and then add the same method to AnsCoder

Check if no data has been encoded yet.

Same as Encoder::maybe_full, but can be called on a concrete type without type annotations.

Same as IntoDecoder::into_decoder(self) but can be used for any PRECISION and therefore doesn’t require type arguments on the caller side.

TODO: there should also be a decoder() method that takes &mut self

Returns the number of compressed words on the ans.

This includes a constant overhead of between one and two words unless the coder is completely empty.

This method returns the length of the slice, the Vec<Word>, or the iterator that would be returned by get_compressed, into_compressed, or iter_compressed, respectively, when called at this time.

See also num_bits.

Returns the size of the current queue of compressed data in bits.

This includes some constant overhead unless the coder is completely empty (see num_words).

The returned value is a multiple of the bitlength of the compressed word type Word.

Low-level constructor that assembles a RangeEncoder from its internal components.

The arguments bulk, state, and situation correspond to the three return values of the method into_raw_parts.

Low-level method that disassembles the RangeEncoder into its internal components.

Can be used together with from_raw_parts.

Discards all compressed data and resets the coder to the same state as Coder::new.

Assembles the current compressed data into a single slice.

This method is only implemented for encoders backed by a Vec<Word> because we have to temporarily seal the encoder and then unseal it when the returned EncoderGuard is dropped, which requires precise knowledge of the backend (and which is also the reason why this method takes a &mut self receiver). If you’re using a different backend than a Vec, consider calling into_compressed instead.

A decoder for temporary use.

Once the returned decoder gets dropped, you can continue using this encoder. If you don’t need this flexibility, call into_decoder instead.

This method is only implemented for encoders backed by a Vec<Word> because we have to temporarily seal the encoder and then unseal it when the returned decoder is dropped, which requires precise knowledge of the backend (and which is also the reason why this method takes a &mut selfreceiver). If you’re using a different backend than a Vec, consider calling into_decoder instead.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
The internal coder state, as returned by the method state. Read more
The smallest unit of compressed data that this coder can emit or read at once. Most coders guarantee that encoding emits at most one Word per symbol (plus a constant overhead).
Returns the current internal state of the coder. Read more
Checks if there might not be any room to encode more data. Read more
Checks if there might be no compressed data left for decoding. Read more
Formats the value using the given formatter. Read more

This is essentially the same as #[derive(Default)], except for the assertions on State::BITS and Word::BITS.

The error type for logical encoding errors. Read more
The error type for writing out encoded data. Read more
Encodes a single symbol with the given entropy model. Read more
Checks if there might not be any room to encode more data. Read more
Encodes a sequence of symbols, each with its individual entropy model. Read more
Encodes a sequence of symbols from a fallible iterator. Read more
Encodes a sequence of symbols, all with the same entropy model. Read more
Converts to this type from the input type.
Converts to this type from the input type.
The target type of the conversion.
Performs the conversion.
Returns the position in the compressed data, in units of Words. 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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.