pub struct RangeDecoder<Word, State, Backend>
where Word: BitArray, State: BitArray, Backend: ReadWords<Word, Queue>,
{ /* private fields */ }

Implementations§

source§

impl<Word, State, Backend> RangeDecoder<Word, State, Backend>
where Word: BitArray + Into<State>, State: BitArray + AsPrimitive<Word>, Backend: ReadWords<Word, Queue>,

source

pub fn from_compressed<Buf>(compressed: Buf) -> Result<Self, Backend::ReadError>
where Buf: IntoReadWords<Word, Queue, IntoReadWords = Backend>,

source

pub fn with_backend(backend: Backend) -> Result<Self, Backend::ReadError>

source

pub fn for_compressed<'a, Buf>( compressed: &'a Buf ) -> Result<Self, Backend::ReadError>
where Buf: AsReadWords<'a, Word, Queue, AsReadWords = Backend>,

source

pub fn from_raw_parts( bulk: Backend, state: RangeCoderState<Word, State>, point: State ) -> Result<Self, Backend>

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

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

The construction fails if the argument point lies outside of the range represented by state. In this case, the method returns the (unmodified) argument bulk back to the caller, wrapped in an Err variant.

source

pub fn into_raw_parts(self) -> (Backend, RangeCoderState<Word, State>, State)

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

Can be used together with from_raw_parts.

source

pub fn maybe_exhausted(&self) -> bool

Same as Decoder::maybe_exhausted, but can be called on a concrete type without type annotations.

Trait Implementations§

source§

impl<Word, State, Backend> Clone for RangeDecoder<Word, State, Backend>
where Word: BitArray + Clone, State: BitArray + Clone, Backend: ReadWords<Word, Queue> + Clone,

source§

fn clone(&self) -> RangeDecoder<Word, State, Backend>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Word, State, Backend> Code for RangeDecoder<Word, State, Backend>
where Word: BitArray + Into<State>, State: BitArray + AsPrimitive<Word>, Backend: ReadWords<Word, Queue>,

§

type State = RangeCoderState<Word, State>

The internal coder state, as returned by the method state. Read more
§

type Word = Word

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).
source§

fn state(&self) -> Self::State

Returns the current internal state of the coder. Read more
source§

fn encoder_maybe_full<const PRECISION: usize>(&self) -> bool
where Self: Encode<PRECISION>,

Checks if there might not be any room to encode more data. Read more
source§

fn decoder_maybe_exhausted<const PRECISION: usize>(&self) -> bool
where Self: Decode<PRECISION>,

Checks if there might be no compressed data left for decoding. Read more
source§

impl<Word, State, Backend> Debug for RangeDecoder<Word, State, Backend>
where Word: BitArray + Debug, State: BitArray + Debug, Backend: ReadWords<Word, Queue> + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Word, State, Backend, const PRECISION: usize> Decode<PRECISION> for RangeDecoder<Word, State, Backend>
where Word: BitArray + Into<State>, State: BitArray + AsPrimitive<Word>, Backend: ReadWords<Word, Queue>,

source§

fn decode_symbol<D>( &mut self, model: D ) -> Result<D::Symbol, CoderError<Self::FrontendError, Self::BackendError>>
where D: DecoderModel<PRECISION>, D::Probability: Into<Self::Word>, Self::Word: AsPrimitive<D::Probability>,

Decodes a single symbol and pops it off the compressed data.

This is a low level method. You usually probably want to call a batch method like decode_symbols or decode_iid_symbols instead.

This method is called decode_symbol rather than decode_symbol to stress the fact that the Coder is a stack: decode_symbol will return the last symbol that was previously encoded via encode_symbol.

Note that this method cannot fail. It will still produce symbols in a deterministic way even if the coder is empty, but such symbols will not recover any previously encoded data and will generally have low entropy. Still, being able to pop off an arbitrary number of symbols can sometimes be useful in edge cases of, e.g., the bits-back algorithm.

§

type FrontendError = DecoderFrontendError

The error type for logical decoding errors. Read more
§

type BackendError = <Backend as ReadWords<Word, Queue>>::ReadError

The error type for reading in encoded data. Read more
source§

fn maybe_exhausted(&self) -> bool

Checks if there might be no compressed data left for decoding. Read more
source§

fn decode_symbols<'s, I, M>( &'s mut self, models: I ) -> DecodeSymbols<'s, Self, I::IntoIter, PRECISION>
where I: IntoIterator<Item = M> + 's, M: DecoderModel<PRECISION>, M::Probability: Into<Self::Word>, Self::Word: AsPrimitive<M::Probability>,

Decodes a sequence of symbols, using an individual entropy model for each symbol. Read more
source§

fn try_decode_symbols<'s, I, M, E>( &'s mut self, models: I ) -> TryDecodeSymbols<'s, Self, I::IntoIter, PRECISION>
where I: IntoIterator<Item = Result<M, E>> + 's, M: DecoderModel<PRECISION>, M::Probability: Into<Self::Word>, Self::Word: AsPrimitive<M::Probability>,

Decodes a sequence of symbols from a fallible iterator over entropy models. Read more
source§

fn decode_iid_symbols<M>( &mut self, amt: usize, model: M ) -> DecodeIidSymbols<'_, Self, M, PRECISION>
where M: DecoderModel<PRECISION> + Copy, M::Probability: Into<Self::Word>, Self::Word: AsPrimitive<M::Probability>,

Decodes amt symbols using the same entropy model for all symbols. Read more
source§

impl<Word, State, Backend> From<RangeEncoder<Word, State, Backend>> for RangeDecoder<Word, State, Backend::IntoReadWords>
where Word: BitArray + Into<State>, State: BitArray + AsPrimitive<Word>, Backend: WriteWords<Word> + IntoReadWords<Word, Queue>,

source§

fn from(encoder: RangeEncoder<Word, State, Backend>) -> Self

Converts to this type from the input type.
source§

impl<Word, State, Backend> PosSeek for RangeDecoder<Word, State, Backend>
where Word: BitArray, State: BitArray, Backend: ReadWords<Word, Queue> + PosSeek, Self: Code,

§

type Position = (<Backend as PosSeek>::Position, <RangeDecoder<Word, State, Backend> as Code>::State)

source§

impl<Word, State, Backend> Seek for RangeDecoder<Word, State, Backend>
where Word: BitArray + Into<State>, State: BitArray + AsPrimitive<Word>, Backend: ReadWords<Word, Queue> + Seek,

source§

fn seek(&mut self, pos_and_state: Self::Position) -> Result<(), ()>

Jumps to a given position in the compressed data. Read more

Auto Trait Implementations§

§

impl<Word, State, Backend> RefUnwindSafe for RangeDecoder<Word, State, Backend>
where Backend: RefUnwindSafe, State: RefUnwindSafe, Word: RefUnwindSafe, <State as BitArray>::NonZero: RefUnwindSafe,

§

impl<Word, State, Backend> Send for RangeDecoder<Word, State, Backend>
where Backend: Send, State: Send, Word: Send, <State as BitArray>::NonZero: Send,

§

impl<Word, State, Backend> Sync for RangeDecoder<Word, State, Backend>
where Backend: Sync, State: Sync, Word: Sync, <State as BitArray>::NonZero: Sync,

§

impl<Word, State, Backend> Unpin for RangeDecoder<Word, State, Backend>
where Backend: Unpin, State: Unpin, Word: Unpin, <State as BitArray>::NonZero: Unpin,

§

impl<Word, State, Backend> UnwindSafe for RangeDecoder<Word, State, Backend>
where Backend: UnwindSafe, State: UnwindSafe, Word: UnwindSafe, <State as BitArray>::NonZero: UnwindSafe,

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.