#[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) -> Self
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.
sourcepub fn from_hex_str(value: &str) -> Result<Self, ParseHashError>
pub fn from_hex_str(value: &str) -> Result<Self, ParseHashError>
Converts a hexadecimal string representation of a hash to a Hash40
sourcepub fn from_label(label: &str) -> Result<Self, FromLabelError>
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.
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: Self) -> Self
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.
sourcepub const fn concat_str(self, other: &str) -> Self
pub const fn concat_str(self, other: &str) -> Self
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: Read + Seek>(
__binrw_generated_var_reader: &mut R,
__binrw_generated_var_endian: Endian,
__binrw_generated_var_arguments: Self::Args<'_>
) -> BinResult<Self>
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>
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: Write + Seek>(
&self,
__binrw_generated_var_writer: &mut W,
__binrw_generated_var_endian: Endian,
__binrw_generated_var_arguments: Self::Args<'_>
) -> BinResult<()>
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<()>
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<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
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 FromStr for Hash40
impl FromStr for Hash40
§type Err = FromLabelError
type Err = FromLabelError
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