Struct hash40::Hash40

source ·
#[repr(transparent)]
pub struct Hash40(pub u64);
Expand description

The central type of the crate, representing a string hashed using the hash40 algorithm Hash40 is a combination of a crc32 checksum and string length appended to the top bits

Tuple Fields§

§0: u64

Implementations§

source§

impl Hash40

source

pub const fn new(string: &str) -> Self

Computes a Hash40 from a string. This method does not respect the static label map, nor does it check to see if the provided string is in hexadecimal format already.

source

pub fn from_hex_str(value: &str) -> Result<Self, ParseHashError>

Converts a hexadecimal string representation of a hash to a Hash40

source

pub fn from_label(label: &str) -> Result<Self, FromLabelError>

Computes a Hash40 from a string. This method checks if the string is a hexadecimal value first. If not, it either searches for a reverse label from the static map or computes a new hash, depending on the form of the static label map.

source

pub fn to_label(&self) -> String

Searches for the label associated with the hash value. If no label is found, returns the hexadecimal value, formatted as 0x0123456789

source

pub const fn crc(self) -> u32

Returns the CRC32 part of the hash

source

pub const fn str_len(self) -> u8

Returns the string length part of the hash

source

pub fn label_map() -> Arc<Mutex<LabelMap>>

A convenience method provided to access the static label map

source

pub const fn concat(self, other: Self) -> Self

Concatenates two Hash40 values, so that the resulting length and CRC would be the same if the original data was all hashed together.

source

pub const fn concat_str(self, other: &str) -> Self

A convenience method for concatenating a string to a Hash40

source

pub const fn join_path(self, other: Self) -> Self

A convenience method for concatenating two Hash40s separated by a path separator

Methods from Deref<Target = u64>§

1.43.0 · source

pub const MIN: u64 = 0u64

1.43.0 · source

pub const MAX: u64 = 18_446_744_073_709_551_615u64

1.53.0 · source

pub const BITS: u32 = 64u32

Trait Implementations§

source§

impl BinRead for Hash40

§

type Args<'__binrw_generated_args_lifetime> = ()

The type used for the args parameter of read_args() and read_options(). Read more
source§

fn read_options<R: Read + Seek>( __binrw_generated_var_reader: &mut R, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: Self::Args<'_> ) -> BinResult<Self>

Read Self from the reader using the given Endian and arguments. Read more
source§

fn read_be<R>(reader: &mut R) -> Result<Self, Error>where R: Read + Seek, Self::Args<'a>: for<'a> Required,

Read Self from the reader using default arguments and assuming big-endian byte order. Read more
source§

fn read_le<R>(reader: &mut R) -> Result<Self, Error>where R: Read + Seek, Self::Args<'a>: for<'a> Required,

Read Self from the reader using default arguments and assuming little-endian byte order. Read more
source§

fn read_ne<R>(reader: &mut R) -> Result<Self, Error>where R: Read + Seek, Self::Args<'a>: for<'a> Required,

Read T from the reader assuming native-endian byte order. Read more
source§

fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>where R: Read + Seek,

Read Self from the reader, assuming big-endian byte order, using the given arguments. Read more
source§

fn read_le_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>where R: Read + Seek,

Read Self from the reader, assuming little-endian byte order, using the given arguments. Read more
source§

fn read_ne_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>where R: Read + Seek,

Read T from the reader, assuming native-endian byte order, using the given arguments. Read more
source§

fn after_parse<R>( &mut self, _: &mut R, _: Endian, _: Self::Args<'_> ) -> Result<(), Error>where R: Read + Seek,

Runs any post-processing steps required to finalize construction of the object. Read more
source§

impl BinWrite for Hash40

§

type Args<'__binrw_generated_args_lifetime> = ()

The type used for the args parameter of write_args() and write_options(). Read more
source§

fn write_options<W: Write + Seek>( &self, __binrw_generated_var_writer: &mut W, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: Self::Args<'_> ) -> BinResult<()>

Write Self to the writer using the given Endian and arguments. Read more
source§

fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>where W: Write + Seek, Self::Args<'a>: for<'a> Required,

Write Self to the writer assuming big-endian byte order. Read more
source§

fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>where W: Write + Seek, Self::Args<'a>: for<'a> Required,

Write Self to the writer assuming little-endian byte order. Read more
source§

fn write_be_args<W>( &self, writer: &mut W, args: Self::Args<'_> ) -> Result<(), Error>where W: Write + Seek,

Write Self to the writer, assuming big-endian byte order, using the given arguments. Read more
source§

fn write_le_args<W>( &self, writer: &mut W, args: Self::Args<'_> ) -> Result<(), Error>where W: Write + Seek,

Write Self to the writer, assuming little-endian byte order, using the given arguments. Read more
source§

impl Clone for Hash40

source§

fn clone(&self) -> Hash40

Returns a copy 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 Hash40

source§

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

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

impl Default for Hash40

source§

fn default() -> Hash40

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

impl Deref for Hash40

§

type Target = u64

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl DerefMut for Hash40

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'de> Deserialize<'de> for Hash40

source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
source§

impl Diff for Hash40

§

type Repr = Option<Hash40>

The type associated with the structs’ difference
source§

fn diff(&self, other: &Self) -> Self::Repr

Produces a diff between two structs
source§

fn apply(&mut self, diff: &Self::Repr)

Applies the diff directly to the struct
source§

fn identity() -> Self

The identity element of the struct Read more
source§

fn diff_custom<D>(&self, other: &Self, visitor: &D) -> <D as Differ<Self>>::Reprwhere D: Differ<Self>,

Produces a diff between two structs, using an external diffing implementation
source§

fn apply_custom<D>(&mut self, diff: &<D as Differ<Self>>::Repr, visitor: &D)where D: Differ<Self>,

Applies the diff directly to the struct, using an external diffing implementation
source§

fn apply_new(&self, diff: &Self::Repr) -> Self

Applies the diff to the struct and produces a new struct
source§

fn apply_new_custom<D>( &self, diff: &<D as Differ<Self>>::Repr, visitor: &D ) -> Selfwhere D: Differ<Self>,

Applies the diff to the struct and produces a new struct, using an external diffing implementation
source§

impl Display for Hash40

source§

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

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

impl FromStr for Hash40

§

type Err = FromLabelError

The associated error which can be returned from parsing.
source§

fn from_str(f: &str) -> Result<Self, FromLabelError>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Hash40

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Hash40

source§

fn cmp(&self, other: &Hash40) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Hash40> for Hash40

source§

fn eq(&self, other: &Hash40) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Hash40> for Hash40

source§

fn partial_cmp(&self, other: &Hash40) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Hash40

source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for Hash40

source§

impl Eq for Hash40

source§

impl StructuralEq for Hash40

source§

impl StructuralPartialEq for Hash40

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CustomError for Twhere T: Display + Debug + Send + Sync + 'static,

source§

fn as_any(&self) -> &(dyn Any + Sync + Send + 'static)

source§

fn as_any_mut(&mut self) -> &mut (dyn Any + Sync + Send + 'static)

source§

fn as_box_any(self: Box<T, Global>) -> Box<dyn Any + Sync + Send, Global>

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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 Twhere T: Clone,

§

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,