Struct constriction::symbol::SymbolCoder [−][src]
Expand description
Generic symbol coder for 3 out of 4 possible cases
You likely won’t spell out this type explicitly. It’s more convenient to use one of the
type aliases QueueEncoder or StackCoder (or the more opinionated aliases
DefaultQueueEncoder and DefaultStackCoder).
Depending on the type parameter S, this type supports:
- encoding on a queue (i.e., writing prefix codes); this is type aliased as
QueueEncoder. - encoding and decoding on a stack (i.e., writing suffix codes and reading them back in
reoverse order). This is type aliased as
StackCoder.
This type does not support decoding from a queue. Use a QueueDecoder for this
purpose.
Implementations
Returns the correct len for, e.g., B = Vec<Word> regardless of whether S = Queue
or S = Stack.
Returns true if no bits are on the SymbolCoder.
pub fn into_decoder(
self
) -> Result<QueueDecoder<Word, B::IntoReadWords>, B::WriteError> where
B: WriteWords<Word> + IntoReadWords<Word, Queue>,
pub fn into_overshooting_iter(
self
) -> Result<impl Iterator<Item = Result<bool, <B::IntoReadWords as ReadWords<Word, Queue>>::ReadError>>, B::WriteError> where
B: WriteWords<Word> + IntoReadWords<Word, Queue>,
pub fn from_compressed(
compressed: B
) -> Result<Self, CoderError<B, B::ReadError>> where
B: ReadWords<Word, Stack>,
pub fn from_compressed(
compressed: B
) -> Result<Self, CoderError<B, B::ReadError>> where
B: ReadWords<Word, Stack>,
Errors
- Returns
Err(CoderError::FrontendError(compressed))ifcompressedends in a zero which is not allowed for stacks (because we need a terminal “one” bit to identify the head position). Note that “EOF” is not considered an error, and the method will return with a success if called with an empty backend. - Returns
Err(CoderError::BackendError(err))if reading the last word from the backend resulted inErr(err). - Returns
Ok(stack_coder)in all other cases, including the case where the backend is empty.
pub fn encode_symbols_reverse<Symbol, C, I>(
&mut self,
symbols_and_codebooks: I
) -> Result<(), CoderError<DefaultEncoderFrontendError, B::WriteError>> where
Symbol: Borrow<C::Symbol>,
C: EncoderCodebook,
I: IntoIterator<Item = (Symbol, C)>,
I::IntoIter: DoubleEndedIterator,
pub fn encode_iid_symbols_reverse<Symbol, C, I>(
&mut self,
symbols: I,
codebook: &C
) -> Result<(), CoderError<DefaultEncoderFrontendError, B::WriteError>> where
Symbol: Borrow<C::Symbol>,
C: EncoderCodebook,
I: IntoIterator<Item = Symbol>,
I::IntoIter: DoubleEndedIterator,
pub fn into_decoder(self) -> SymbolCoder<Word, Stack, B::IntoReadWords> where
B: IntoReadWords<Word, Stack>,
pub fn as_decoder<'a>(&'a self) -> SymbolCoder<Word, Stack, B::AsReadWords> where
B: AsReadWords<'a, Word, Stack>,
pub fn into_iterator(
self
) -> impl Iterator<Item = Result<bool, <B::IntoReadWords as ReadWords<Word, Stack>>::ReadError>> where
B: IntoReadWords<Word, Stack>,
pub fn into_iterator(
self
) -> impl Iterator<Item = Result<bool, <B::IntoReadWords as ReadWords<Word, Stack>>::ReadError>> where
B: IntoReadWords<Word, Stack>,
Consumes the coder and returns an iterator over bits (in reverse direction)
You often don’t need to call this method since a StackCoder is already an iterator
if the backend implements ReadWords<Word, Stack> (as the default backend
Vec<Word> does).
pub fn iter<'a>(
&'a self
) -> impl Iterator<Item = Result<bool, <<B as AsReadWords<'a, Word, Stack>>::AsReadWords as ReadWords<Word, Stack>>::ReadError>> + 'a where
B: AsReadWords<'a, Word, Stack>,
pub fn iter<'a>(
&'a self
) -> impl Iterator<Item = Result<bool, <<B as AsReadWords<'a, Word, Stack>>::AsReadWords as ReadWords<Word, Stack>>::ReadError>> + 'a where
B: AsReadWords<'a, Word, Stack>,
Returns an iterator over bits (in reverse direction) that leaves the current coder untouched.
You often don’t need to call this method since a StackCoder is already an iterator
if the backend implements ReadWords<Word, Stack> (as the default backend
Vec<Word> does).
Trait Implementations
Returns the “default value” for a type. Read more
impl<Word: PartialEq + BitArray, S: PartialEq + Semantics, B: PartialEq> PartialEq<SymbolCoder<Word, S, B>> for SymbolCoder<Word, S, B>
impl<Word: PartialEq + BitArray, S: PartialEq + Semantics, B: PartialEq> PartialEq<SymbolCoder<Word, S, B>> for SymbolCoder<Word, S, B>
This method tests for self and other values to be equal, and is used
by ==. Read more
This method tests for !=.
Auto Trait Implementations
impl<Word, S, B> RefUnwindSafe for SymbolCoder<Word, S, B> where
B: RefUnwindSafe,
S: RefUnwindSafe,
Word: RefUnwindSafe,
impl<Word, S, B> Send for SymbolCoder<Word, S, B> where
B: Send,
S: Send,
Word: Send,
impl<Word, S, B> Sync for SymbolCoder<Word, S, B> where
B: Sync,
S: Sync,
Word: Sync,
impl<Word, S, B> Unpin for SymbolCoder<Word, S, B> where
B: Unpin,
S: Unpin,
Word: Unpin,
impl<Word, S, B> UnwindSafe for SymbolCoder<Word, S, B> where
B: UnwindSafe,
S: UnwindSafe,
Word: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
