Skip to main content

HashCodeMap

Struct HashCodeMap 

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

A container for associating hashes with their original label and vice versa.

Implementations§

Source§

impl HashCodeMap

Source

pub fn get() -> Arc<Mutex<Self>>

Returns a thread-safe reference-counting pointer to the mutually exclusive HashCodeMap.

Source

pub fn label_of(&self, hash: HashCode, width: Option<u32>) -> Option<&String>

Returns a reference to the label corresponding to the hash.

Source

pub fn hash_of(&self, label: &str) -> Option<HashCode>

Returns the hash corresponding to the label.

Source

pub fn extend_shift_jis<I: IntoIterator<Item = String>>( &mut self, iter: I, ) -> Result<(), ParseLabelError>

Hashes and inserts a collection of labels from an iterator, converting to Shift JIS.

Source

pub fn extend_utf8<I: IntoIterator<Item = String>>( &mut self, iter: I, ) -> Result<(), ParseLabelError>

Hashes and inserts a collection of labels from an iterator, interpreting as UTF-8.

Source

pub fn read_shift_jis<P: AsRef<Path>>( &mut self, path: P, ) -> Result<(), ParseLabelError>

Reads and hashes a newline-separated list of labels from a file, converting to Shift JIS.

Source

pub fn read_utf8<P: AsRef<Path>>( &mut self, path: P, ) -> Result<(), ParseLabelError>

Reads and hashes a newline-separated list of labels from a file, interpreting as UTF-8.

Source

pub fn set_strict(&mut self, strict: bool)

Updates whether foreign labels should be rejected when looking up the hash of a label.

Source

pub fn clear(&mut self)

Clears the map, removing all key-value pairs. Keeps the allocated memory for reuse.

Source

pub fn reset(&mut self)

Clears the map, removing all key-value pairs and resets additional configuration. Keeps the allocated memory for reuse.

Trait Implementations§

Source§

impl Debug for HashCodeMap

Source§

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

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

impl Default for HashCodeMap

Source§

fn default() -> HashCodeMap

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