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
Methods from Deref<Target = u64>§
pub const MIN: u64 = 0u64
pub const MAX: u64 = 18_446_744_073_709_551_615u64
pub const BITS: u32 = 64u32
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>where
R: Read + Seek,
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,
source§fn read_be<R>(reader: &mut R) -> Result<Self, Error>where
R: Read + Seek,
Self::Args<'a>: for<'a> Required,
fn read_be<R>(reader: &mut R) -> Result<Self, Error>where R: Read + Seek, Self::Args<'a>: for<'a> Required,
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>where
R: Read + Seek,
Self::Args<'a>: for<'a> Required,
fn read_le<R>(reader: &mut R) -> Result<Self, Error>where R: Read + Seek, Self::Args<'a>: for<'a> Required,
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>where
R: Read + Seek,
Self::Args<'a>: for<'a> Required,
fn read_ne<R>(reader: &mut R) -> Result<Self, Error>where R: Read + Seek, Self::Args<'a>: for<'a> Required,
T
from the reader assuming native-endian byte order. Read moresource§fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>where
R: Read + Seek,
fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>where R: Read + Seek,
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>where
R: Read + Seek,
fn read_le_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>where R: Read + Seek,
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>where
W: Write + Seek,
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,
source§fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>where
W: Write + Seek,
Self::Args<'a>: for<'a> Required,
fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>where W: Write + Seek, Self::Args<'a>: for<'a> Required,
Self
to the writer assuming big-endian byte order. Read moresource§fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>where
W: Write + Seek,
Self::Args<'a>: for<'a> Required,
fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>where W: Write + Seek, Self::Args<'a>: for<'a> Required,
Self
to the writer assuming little-endian byte order. 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
§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>,
§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>,
§fn apply_new(&self, diff: &Self::Repr) -> Self
fn apply_new(&self, diff: &Self::Repr) -> Self
§fn apply_new_custom<D>(
&self,
diff: &<D as Differ<Self>>::Repr,
visitor: &D
) -> Selfwhere
D: Differ<Self>,
fn apply_new_custom<D>( &self, diff: &<D as Differ<Self>>::Repr, visitor: &D ) -> Selfwhere D: Differ<Self>,
source§impl Ord for Hash40
impl Ord for Hash40
source§impl PartialEq<Hash40> for Hash40
impl PartialEq<Hash40> for Hash40
source§impl PartialOrd<Hash40> for Hash40
impl PartialOrd<Hash40> for Hash40
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more