pub struct Hash128(pub [u8; 16]);Expand description
128-bit hash of a whole normalized representation.
Tuple Fields§
§0: [u8; 16]Implementations§
Source§impl Hash128
impl Hash128
Sourcepub fn of_tokens(tokens: &[String]) -> Hash128
pub fn of_tokens(tokens: &[String]) -> Hash128
Hash of a token sequence: the first 128 bits of BLAKE3 over the tokens, each
followed by a separator, so that ["ab", "c"] and ["a", "bc"] differ.
§Examples
use pelicode_core::Hash128;
let tokens = |s: &str| s.split(' ').map(String::from).collect::<Vec<_>>();
assert_eq!(Hash128::of_tokens(&tokens("a b")), Hash128::of_tokens(&tokens("a b")));
assert_ne!(Hash128::of_tokens(&tokens("ab c")), Hash128::of_tokens(&tokens("a bc")));Sourcepub fn to_hex(&self) -> String
pub fn to_hex(&self) -> String
The hash as 32 lower-case hexadecimal digits.
§Examples
use pelicode_core::Hash128;
assert_eq!(Hash128([0xab; 16]).to_hex(), "ab".repeat(16));Sourcepub fn from_hex(hex: &str) -> Option<Hash128>
pub fn from_hex(hex: &str) -> Option<Hash128>
Parses 32 hexadecimal digits, as written by Hash128::to_hex; None for anything else.
§Examples
use pelicode_core::Hash128;
let hash = Hash128([0x01; 16]);
assert_eq!(Hash128::from_hex(&hash.to_hex()), Some(hash));
assert_eq!(Hash128::from_hex("not a hash"), None);Trait Implementations§
impl Copy for Hash128
impl Eq for Hash128
Source§impl Ord for Hash128
impl Ord for Hash128
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Hash128
impl PartialOrd for Hash128
impl StructuralPartialEq for Hash128
Auto Trait Implementations§
impl Freeze for Hash128
impl RefUnwindSafe for Hash128
impl Send for Hash128
impl Sync for Hash128
impl Unpin for Hash128
impl UnsafeUnpin for Hash128
impl UnwindSafe for Hash128
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more