Struct 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) -> Hash40

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<Hash40, ParseHashError>

Converts a hexadecimal string representation of a hash to a Hash40

Source

pub fn from_label(label: &str) -> Result<Hash40, 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: Hash40) -> Hash40

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) -> Hash40

A convenience method for concatenating a string to a Hash40

Source

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

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

Source§

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>( __binrw_generated_var_reader: &mut R, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: <Hash40 as BinRead>::Args<'_>, ) -> Result<Hash40, Error>
where R: Read + Seek,

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

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

Read Self from the reader using default 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_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
where R: Read + Seek, Self: ReadEndian,

Read Self from the reader using the given arguments. 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

Source§

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>( &self, __binrw_generated_var_writer: &mut W, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: <Hash40 as BinWrite>::Args<'_>, ) -> Result<(), Error>
where W: Write + Seek,

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

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

Write Self to the writer using default 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_args<W>( &self, writer: &mut W, args: Self::Args<'_>, ) -> Result<(), Error>
where W: Write + Seek, Self: WriteEndian,

Write Self to the writer using the given arguments. 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 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 Hash40

Source§

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

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

Source§

type Target = u64

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<Hash40 as Deref>::Target

Dereferences the value.
Source§

impl DerefMut for Hash40

Source§

fn deref_mut(&mut self) -> &mut <Hash40 as Deref>::Target

Mutably dereferences the value.
Source§

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

Source§

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

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

impl Diff for Hash40

Source§

type Repr = Option<Hash40>

The type associated with the structs’ difference
Source§

fn diff(&self, other: &Hash40) -> <Hash40 as Diff>::Repr

Produces a diff between two structs
Source§

fn apply(&mut self, diff: &<Hash40 as Diff>::Repr)

Applies the diff directly to the struct
Source§

fn identity() -> Hash40

The identity element of the struct Read more
Source§

fn diff_custom<D>(&self, other: &Self, visitor: &D) -> <D as Differ<Self>>::Repr
where 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, ) -> Self
where 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<(), Error>

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

impl From<Hash40> for Value

Source§

fn from(value: Hash40) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Hash40

Source§

type Err = FromLabelError

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

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

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

impl Hash for Hash40

Source§

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

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) -> Self
where Self: Sized,

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

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

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

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

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

impl PartialEq for Hash40

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd 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

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

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

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

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>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

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

impl Copy for Hash40

Source§

impl Eq for Hash40

Source§

impl StructuralPartialEq for Hash40

Auto Trait Implementations§

§

impl Freeze for Hash40

§

impl RefUnwindSafe for Hash40

§

impl Send for Hash40

§

impl Sync for Hash40

§

impl Unpin for Hash40

§

impl UnwindSafe for Hash40

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,