#[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: u64Implementations§
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
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>
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_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: 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>
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§impl<'de> Deserialize<'de> for Hash40
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Hash40
serde only.