Struct constriction::stream::queue::RangeDecoder
source · 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>,
impl<Word, State, Backend> RangeDecoder<Word, State, Backend>where
Word: BitArray + Into<State>,
State: BitArray + AsPrimitive<Word>,
Backend: ReadWords<Word, Queue>,
pub fn from_compressed<Buf>(compressed: Buf) -> Result<Self, Backend::ReadError>where
Buf: IntoReadWords<Word, Queue, IntoReadWords = Backend>,
pub fn with_backend(backend: Backend) -> Result<Self, Backend::ReadError>
pub fn for_compressed<'a, Buf>(
compressed: &'a Buf
) -> Result<Self, Backend::ReadError>where
Buf: AsReadWords<'a, Word, Queue, AsReadWords = Backend>,
sourcepub fn from_raw_parts(
bulk: Backend,
state: RangeCoderState<Word, State>,
point: State
) -> Result<Self, Backend>
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.
sourcepub fn into_raw_parts(self) -> (Backend, RangeCoderState<Word, State>, State)
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.
sourcepub fn maybe_exhausted(&self) -> bool
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,
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>
fn clone(&self) -> RangeDecoder<Word, State, Backend>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<Word, State, Backend> Code for RangeDecoder<Word, State, Backend>where
Word: BitArray + Into<State>,
State: BitArray + AsPrimitive<Word>,
Backend: ReadWords<Word, Queue>,
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>
type State = RangeCoderState<Word, State>
§type Word = Word
type Word = Word
Word per symbol (plus a constant
overhead).source§impl<Word, State, Backend> Debug for RangeDecoder<Word, State, Backend>where
Word: BitArray + Debug,
State: BitArray + Debug,
Backend: ReadWords<Word, Queue> + Debug,
impl<Word, State, Backend> Debug for RangeDecoder<Word, State, Backend>where
Word: BitArray + Debug,
State: BitArray + Debug,
Backend: ReadWords<Word, Queue> + Debug,
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>,
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>,
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
type FrontendError = DecoderFrontendError
§type BackendError = <Backend as ReadWords<Word, Queue>>::ReadError
type BackendError = <Backend as ReadWords<Word, Queue>>::ReadError
source§fn maybe_exhausted(&self) -> bool
fn maybe_exhausted(&self) -> bool
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>,
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>,
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>,
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>,
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>,
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>,
amt symbols using the same entropy model for all symbols. Read more