Decoder

Struct Decoder 

Source
pub struct Decoder { /* private fields */ }
Expand description

The Fast Static Symbol Table (FSST) decoder.

See module level documentations. Note that this struct contains a ~2KiB large array, and you may want to box it for fast moving.

Implementations§

Source§

impl Decoder

Source

pub const MAX_SYMBOL_LEN: usize = 8usize

The max length of one symbol.

Source

pub fn parse(bytes: &[u8]) -> Result<Self, Error>

Parse the symbol table symtab, from the serialization format from libfstt.

This is re-implemented in Rust with the reference of libfstt’s fsst_import.

Some notable differences:

  • More error checking on short inputs, no buffer overflow, because we’re Rust.
  • More permissive on version endianness. Allow both little and big endian versions. Symbols are still always little-endian, as upstream.
  • Zero-terminated mode (NUL as the first symbol) is unsupported and rejected.
  • Encoder state bytes are ignored.
  • Trailing bytes are allowed but ignored.

License of libfstt: MIT License, Copyright 2018-2020, CWI, TU Munich, FSU Jena

§Errors

Returns None if the input cannot be successfully parsed.

Source

pub fn max_decode_len(input_len: usize) -> usize

Return the max possible decoded length of input_len length input.

Source

pub fn decode_into( &self, input: &[u8], output: &mut [u8], ) -> Result<usize, Error>

Decode input into output and return the number of decoded length.

§Errors

If output.len() < Self::max_decode_len(input.len()), or an error occurs during decoding, None is returned.

Source

pub fn decode(&self, input: &[u8]) -> Result<BString, Error>

Decode input into an owned byte string.

§Errors

If an error occurs during decoding, None is returned.

Trait Implementations§

Source§

impl Debug for Decoder

Source§

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

Formats the value using the given formatter. 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> 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> Same for T

Source§

type Output = T

Should always be Self
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.