Skip to main content

Encoder

Trait Encoder 

Source
pub trait Encoder {
    // Required methods
    fn construct(text: &[u32]) -> Self;
    fn encode(&self, t: u32) -> Option<(u32, u8)>;
    fn decode(&self, e: u32, s: u8) -> Option<u32>;
    fn symbols(&self) -> usize;
}
Expand description

Encoder captures prefix-free codes from a text document. It is necessary that codes be prefix-free starting with the least significant bit.

Required Methods§

Source

fn construct(text: &[u32]) -> Self

Construct a new encoder, returning Err if the text is not amenable to encoding (usually because there are too many symbols in the text).

Source

fn encode(&self, t: u32) -> Option<(u32, u8)>

Encode symbol t, returning None if t is not a symbol of the text.

Source

fn decode(&self, e: u32, s: u8) -> Option<u32>

Decode the symbol e that is of size s bits.

Source

fn symbols(&self) -> usize

The number of symbols in the encoder.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§