Struct constriction::symbol::SymbolCoder[][src]

pub struct SymbolCoder<Word: BitArray, S: Semantics, B = Vec<Word>> { /* fields omitted */ }
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.

Errors
  • Returns Err(CoderError::FrontendError(compressed)) if compressed ends 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 in Err(err).
  • Returns Ok(stack_coder) in all other cases, including the case where the backend is empty.

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

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 a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Performs the conversion.

Performs the conversion.

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.