pub struct ContentDigest {
pub length: u64,
pub fnv1a64: u64,
}Expand description
What: The length and hash of one file’s bytes. Why: A truncated file differs in length and a file with unwritten or foreign bytes differs in hash.
In TS you’d write (pseudocode):
type ContentDigest = { length: number; fnv1a64: bigint };Fields§
§length: u64Number of bytes.
fnv1a64: u64FNV-1a 64-bit hash of the bytes.
Implementations§
Source§impl ContentDigest
impl ContentDigest
Sourcepub fn hash_text(&self) -> String
pub fn hash_text(&self) -> String
What: The hash as the 16 lowercase hexadecimal digits a record stores. Why: JSON numbers cannot carry 64 bits exactly.
In TS you’d write (pseudocode):
digest.fnv1a64.toString(16).padStart(16, '0')Sourcepub fn from_record(length: u64, hash_text: &str) -> Option<ContentDigest>
pub fn from_record(length: u64, hash_text: &str) -> Option<ContentDigest>
What: The digest a record’s length and hexadecimal hash text describe, or nothing when the text is not exactly 16 lowercase hexadecimal digits. Why: A record that spells the hash any other way is damaged, and the caller reports it as a malformed record.
In TS you’d write (pseudocode):
/^[0-9a-f]{16}$/.test(text) ? { length, fnv1a64: BigInt(`0x${text}`) } : undefinedTrait Implementations§
Source§impl Clone for ContentDigest
impl Clone for ContentDigest
impl Copy for ContentDigest
Source§impl Debug for ContentDigest
impl Debug for ContentDigest
impl Eq for ContentDigest
Source§impl PartialEq for ContentDigest
impl PartialEq for ContentDigest
impl StructuralPartialEq for ContentDigest
Auto Trait Implementations§
impl Freeze for ContentDigest
impl RefUnwindSafe for ContentDigest
impl Send for ContentDigest
impl Sync for ContentDigest
impl Unpin for ContentDigest
impl UnsafeUnpin for ContentDigest
impl UnwindSafe for ContentDigest
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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