pub struct Hash {
pub value: HashValue,
}Expand description
A Kind::Hash value: a hash and its stored width.
A Hash value occupies 4 or 8 bytes in a file. The property defines the width. A reader
returns each value with the width that the file stores. The writer writes each value with the
width of the value.
§Examples
use ltk_hash::{BinHash, Hash as _, HashValue, HashWidth};
use ltk_meta::{property::values, traits::PropertyExt as _};
let narrow = values::Hash::new(BinHash::hash_str("weapon"));
assert_eq!(narrow.width(), HashWidth::W4);
assert_eq!(narrow.size_no_header(), 4);
let wide = values::Hash::new(HashValue::wide(0x5d07_ca0d_22ff_9588));
assert_eq!(wide.size_no_header(), 8);Fields§
§value: HashValueImplementations§
Methods from Deref<Target = HashValue>§
Sourcepub fn try_as_u32(self) -> Option<u32>
pub fn try_as_u32(self) -> Option<u32>
Returns the hash as u32 if the width is 4. Returns None if the width is 8.
Sourcepub fn try_as_bin_hash(self) -> Option<BinHash>
pub fn try_as_bin_hash(self) -> Option<BinHash>
Returns the hash as a BinHash if the width is 4. Returns None if the width is 8.
Trait Implementations§
impl ContainerItem for Hash
impl Eq for Hash
Source§impl From<Hash> for PropertyValueEnum
impl From<Hash> for PropertyValueEnum
Source§impl FromValue for Hash
impl FromValue for Hash
Source§fn from_value(value: &PropertyValueEnum) -> Option<&Self>
fn from_value(value: &PropertyValueEnum) -> Option<&Self>
The value as
Self, if that is its kind.Source§fn from_value_mut(value: &mut PropertyValueEnum) -> Option<&mut Self>
fn from_value_mut(value: &mut PropertyValueEnum) -> Option<&mut Self>
Source§impl PropertyExt for Hash
impl PropertyExt for Hash
Source§impl ReadProperty for Hash
impl ReadProperty for Hash
Source§fn from_reader<R: Read + ?Sized>(
reader: &mut R,
_legacy: bool,
) -> Result<Self, Error>
fn from_reader<R: Read + ?Sized>( reader: &mut R, _legacy: bool, ) -> Result<Self, Error>
Reads a Hash value of 4 bytes.
No declared size contains a value that is read on its own.
Hash::from_reader_with_width reads a value of a given width.
impl StructuralPartialEq for Hash
Auto Trait Implementations§
impl Freeze for Hash
impl RefUnwindSafe for Hash
impl Send for Hash
impl Sync for Hash
impl Unpin for Hash
impl UnsafeUnpin for Hash
impl UnwindSafe for Hash
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
Compare self to
key and return true if they are equal.