Dictionary

Struct Dictionary 

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

Represents an encoding dictionary with its characters and configuration.

An dictionary defines the character set and encoding mode used for converting binary data to text. Supports three modes: mathematical base conversion, chunked (RFC 4648), and byte-range mapping.

Implementations§

Source§

impl Dictionary

Source

pub fn builder() -> DictionaryBuilder

Creates a new DictionaryBuilder for constructing a Dictionary.

§Example
use base_d::{Dictionary, EncodingMode};
let dict = Dictionary::builder()
    .chars_from_str("0123456789ABCDEF")
    .mode(EncodingMode::Radix)
    .build()
    .unwrap();
Source

pub fn new(chars: Vec<char>) -> Result<Self, String>

👎Deprecated since 0.1.0: Use Dictionary::builder() instead

Creates a new dictionary with default settings (Radix mode, no padding).

§Arguments
  • chars - Vector of characters to use in the dictionary
§Errors

Returns an error if the dictionary is empty or contains duplicate characters.

§Deprecated

Use Dictionary::builder() instead for more flexible configuration.

Source

pub fn new_with_mode( chars: Vec<char>, mode: EncodingMode, padding: Option<char>, ) -> Result<Self, String>

👎Deprecated since 0.1.0: Use Dictionary::builder() instead

Creates a new dictionary with specified encoding mode and optional padding.

§Arguments
  • chars - Vector of characters to use in the dictionary
  • mode - Encoding mode (Radix, Chunked, or ByteRange)
  • padding - Optional padding character (typically ‘=’ for RFC modes)
§Errors

Returns an error if:

  • The dictionary is empty or contains duplicates
  • Chunked mode is used with a non-power-of-two dictionary size
§Deprecated

Use Dictionary::builder() instead for more flexible configuration.

Source

pub fn new_with_mode_and_range( chars: Vec<char>, mode: EncodingMode, padding: Option<char>, start_codepoint: Option<u32>, ) -> Result<Self, String>

👎Deprecated since 0.1.0: Use Dictionary::builder() instead

Creates a new dictionary with full configuration including byte-range support.

§Arguments
  • chars - Vector of characters (empty for ByteRange mode)
  • mode - Encoding mode
  • padding - Optional padding character
  • start_codepoint - Starting Unicode codepoint for ByteRange mode
§Errors

Returns an error if configuration is invalid for the specified mode.

§Deprecated

Use Dictionary::builder() instead for more flexible configuration.

Source

pub fn from_str(s: &str) -> Result<Self, String>

👎Deprecated since 0.1.0: Use Dictionary::builder().chars_from_str(s).build() instead

Creates an dictionary from a string of characters.

§Arguments
  • s - String containing the dictionary characters
§Deprecated

Use Dictionary::builder().chars_from_str(s).build() instead.

Source

pub fn base(&self) -> usize

Returns the base (radix) of the dictionary.

For ByteRange mode, always returns 256. Otherwise returns the number of characters.

Source

pub fn mode(&self) -> &EncodingMode

Returns the encoding mode of this dictionary.

Source

pub fn padding(&self) -> Option<char>

Returns the padding character, if any.

Source

pub fn start_codepoint(&self) -> Option<u32>

Returns the starting Unicode codepoint for ByteRange mode.

Source

pub fn encode_digit(&self, digit: usize) -> Option<char>

Encodes a digit (0 to base-1) as a character.

Returns None if the digit is out of range.

Source

pub fn decode_char(&self, c: char) -> Option<usize>

Decodes a character back to its digit value.

Returns None if the character is not in the dictionary.

Source

pub fn simd_metadata(&self) -> DictionaryMetadata

Returns SIMD metadata for this dictionary.

This provides information about whether SIMD acceleration is available for this dictionary and which implementation to use.

Source

pub fn simd_available(&self) -> bool

Returns whether SIMD acceleration is available for this dictionary.

This is a convenience method that checks if SIMD can be used with the current CPU features and dictionary configuration.

Trait Implementations§

Source§

impl Clone for Dictionary

Source§

fn clone(&self) -> Dictionary

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 Dictionary

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> 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> Same for T

Source§

type Output = T

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V