#[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
impl Hash40
Sourcepub const fn new(string: &str) -> Hash40
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.
Sourcepub fn from_hex_str(value: &str) -> Result<Hash40, ParseHashError>
pub fn from_hex_str(value: &str) -> Result<Hash40, ParseHashError>
Converts a hexadecimal string representation of a hash to a Hash40
Sourcepub fn from_label(label: &str) -> Result<Hash40, FromLabelError>
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.
Sourcepub fn to_label(&self) -> String
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
Sourcepub fn label_map() -> Arc<Mutex<LabelMap>>
pub fn label_map() -> Arc<Mutex<LabelMap>>
A convenience method provided to access the static label map
Sourcepub const fn concat(self, other: Hash40) -> Hash40
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.
Sourcepub const fn concat_str(self, other: &str) -> Hash40
pub const fn concat_str(self, other: &str) -> Hash40
A convenience method for concatenating a string to a Hash40
Trait Implementations§
Source§impl BinRead for Hash40
impl BinRead for Hash40
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>
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>
Source§fn read<R>(reader: &mut R) -> Result<Self, Error>
fn read<R>(reader: &mut R) -> Result<Self, Error>
Self
from the reader using default arguments. Read moreSource§fn read_be<R>(reader: &mut R) -> Result<Self, Error>
fn read_be<R>(reader: &mut R) -> Result<Self, Error>
Self
from the reader using default arguments and assuming
big-endian byte order. Read moreSource§fn read_le<R>(reader: &mut R) -> Result<Self, Error>
fn read_le<R>(reader: &mut R) -> Result<Self, Error>
Self
from the reader using default arguments and assuming
little-endian byte order. Read moreSource§fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
T
from the reader assuming native-endian byte order. Read moreSource§fn read_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
fn read_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
Self
from the reader using the given arguments. Read moreSource§fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
Self
from the reader, assuming big-endian byte order, using the
given arguments. Read moreSource§fn read_le_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
fn read_le_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
Self
from the reader, assuming little-endian byte order, using
the given arguments. Read moreSource§impl BinWrite for Hash40
impl BinWrite for Hash40
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>
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>
Source§fn write<W>(&self, writer: &mut W) -> Result<(), Error>
fn write<W>(&self, writer: &mut W) -> Result<(), Error>
Self
to the writer using default arguments. Read moreSource§fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
Self
to the writer assuming big-endian byte order. Read moreSource§fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
Self
to the writer assuming little-endian byte order. Read moreSource§fn write_args<W>(
&self,
writer: &mut W,
args: Self::Args<'_>,
) -> Result<(), Error>
fn write_args<W>( &self, writer: &mut W, args: Self::Args<'_>, ) -> Result<(), Error>
Self
to the writer using the given arguments. Read moreSource§impl<'de> Deserialize<'de> for Hash40
impl<'de> Deserialize<'de> for Hash40
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Hash40, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Hash40, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Diff for Hash40
impl Diff for Hash40
Source§fn diff_custom<D>(&self, other: &Self, visitor: &D) -> <D as Differ<Self>>::Reprwhere
D: Differ<Self>,
fn diff_custom<D>(&self, other: &Self, visitor: &D) -> <D as Differ<Self>>::Reprwhere
D: Differ<Self>,
Source§fn apply_custom<D>(&mut self, diff: &<D as Differ<Self>>::Repr, visitor: &D)where
D: Differ<Self>,
fn apply_custom<D>(&mut self, diff: &<D as Differ<Self>>::Repr, visitor: &D)where
D: Differ<Self>,
Source§impl Ord for Hash40
impl Ord for Hash40
Source§impl PartialOrd for Hash40
impl PartialOrd for Hash40
Source§impl Serialize for Hash40
impl Serialize for Hash40
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl Copy for Hash40
impl Eq for Hash40
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> CustomError for T
impl<T> CustomError for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.