#[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) -> 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 more