Struct HuffmanTree

Source
pub(crate) struct HuffmanTree(HuffmanTreeInner);
Expand description

Huffman tree

Tuple Fields§

§0: HuffmanTreeInner

Implementations§

Source§

impl HuffmanTree

Source

pub(crate) fn build_implicit( code_lengths: Vec<u16>, ) -> Result<Self, DecodingError>

Builds a tree implicitly, just from code lengths

Source

pub(crate) const fn build_single_node(symbol: u16) -> Self

Source

pub(crate) fn build_two_node(zero: u16, one: u16) -> Self

Source

pub(crate) const fn is_single_node(&self) -> bool

Source

fn read_symbol_slowpath<R: BufRead>( tree: &[HuffmanTreeNode], v: usize, start_index: usize, bit_reader: &mut BitReader<R>, ) -> Result<u16, DecodingError>

Source

pub(crate) fn read_symbol<R: BufRead>( &self, bit_reader: &mut BitReader<R>, ) -> Result<u16, DecodingError>

Reads a symbol using the bit reader.

You must call call bit_reader.fill() before calling this function or it may erroroneosly detect the end of the stream and return a bitstream error.

Source

pub(crate) fn peek_symbol<R: BufRead>( &self, bit_reader: &BitReader<R>, ) -> Option<(u8, u16)>

Peek at the next symbol in the bitstream if it can be read with only a primary table lookup.

Returns a tuple of the codelength and symbol value. This function may return wrong information if there aren’t enough bits in the bit reader to read the next symbol.

Trait Implementations§

Source§

impl Clone for HuffmanTree

Source§

fn clone(&self) -> HuffmanTree

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HuffmanTree

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for HuffmanTree

Source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.