Struct constriction::stream::queue::RangeDecoder[][src]

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

Implementations

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

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

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

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

pub fn from_raw_parts(
    _bulk: Backend,
    _state: State
) -> Result<Self, (Backend, RangeCoderState<Word, State>)>
[src]

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

pub fn maybe_exhausted(&self) -> bool[src]

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

Trait Implementations

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

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). Read more

fn state(&self) -> Self::State[src]

Returns the current internal state of the coder. Read more

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

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

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

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

impl<Word: Debug, State: Debug, Backend: Debug> Debug for RangeDecoder<Word, State, Backend> where
    Word: BitArray,
    State: BitArray,
    Backend: ReadWords<Word, Queue>, 
[src]

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

Formats the value using the given formatter. Read more

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>, 
[src]

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>, 
[src]

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::ReadError

The error type for reading in encoded data. Read more

fn maybe_exhausted(&self) -> bool[src]

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

fn decode_symbols<'s, I, M>(
    &'s mut self,
    models: I
) -> DecodeSymbols<'s, Self, I::IntoIter, PRECISION>

Notable traits for DecodeSymbols<'a, Decoder, I, PRECISION>

impl<'a, Decoder, I, D, const PRECISION: usize> Iterator for DecodeSymbols<'a, Decoder, I, PRECISION> where
    Decoder: Decode<PRECISION>,
    I: Iterator<Item = D>,
    D: DecoderModel<PRECISION>,
    Decoder::Word: AsPrimitive<D::Probability>,
    D::Probability: Into<Decoder::Word>, 
type Item = Result<<I::Item as EntropyModel<PRECISION>>::Symbol, CoderError<Decoder::FrontendError, Decoder::BackendError>>;
where
    I: IntoIterator<Item = M> + 's,
    M: DecoderModel<PRECISION>,
    M::Probability: Into<Self::Word>,
    Self::Word: AsPrimitive<M::Probability>, 
[src]

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

fn try_decode_symbols<'s, I, M, E>(
    &'s mut self,
    models: I
) -> TryDecodeSymbols<'s, Self, I::IntoIter, PRECISION>

Notable traits for TryDecodeSymbols<'a, Decoder, I, PRECISION>

impl<'a, Decoder, I, D, E, const PRECISION: usize> Iterator for TryDecodeSymbols<'a, Decoder, I, PRECISION> where
    Decoder: Decode<PRECISION>,
    I: Iterator<Item = Result<D, E>>,
    D: DecoderModel<PRECISION>,
    Decoder::Word: AsPrimitive<D::Probability>,
    D::Probability: Into<Decoder::Word>, 
type Item = Result<D::Symbol, TryCodingError<CoderError<Decoder::FrontendError, Decoder::BackendError>, E>>;
where
    I: IntoIterator<Item = Result<M, E>> + 's,
    M: DecoderModel<PRECISION>,
    M::Probability: Into<Self::Word>,
    Self::Word: AsPrimitive<M::Probability>, 
[src]

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

fn decode_iid_symbols<M>(
    &mut self,
    amt: usize,
    model: M
) -> DecodeIidSymbols<'_, Self, M, PRECISION>

Notable traits for DecodeIidSymbols<'a, Decoder, M, PRECISION>

impl<'a, Decoder, M, const PRECISION: usize> Iterator for DecodeIidSymbols<'a, Decoder, M, PRECISION> where
    Decoder: Decode<PRECISION>,
    M: DecoderModel<PRECISION> + Copy,
    Decoder::Word: AsPrimitive<M::Probability>,
    M::Probability: Into<Decoder::Word>, 
type Item = Result<M::Symbol, CoderError<Decoder::FrontendError, Decoder::BackendError>>;
where
    M: DecoderModel<PRECISION> + Copy,
    M::Probability: Into<Self::Word>,
    Self::Word: AsPrimitive<M::Probability>, 
[src]

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

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>, 
[src]

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

Performs the conversion.

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

type Position = (Backend::Position, Self::State)

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

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

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.