pub struct RawHasher {
digest: Sha256,
size: u64,
}Expand description
A raw-block CID computed over bytes that arrive a chunk at a time.
Cid::of_raw needs the whole block in hand, which is the one thing a
blob upload must never have: a personal data server that buffers a body
before it hashes it is holding the whole file in memory to learn its name
(a known defect in jacquard’s uploadBlob). This is the same
hash, fed incrementally, so the bytes can go to their destination as they
arrive and the name falls out at the end.
It counts as it hashes, because the size is the other half of a blob reference and a caller that tracked it separately could disagree with the bytes that were actually hashed.
use didbot_data::{Cid, RawHasher};
let mut hasher = RawHasher::new();
hasher.update(b"quernstone");
hasher.update(b"-farthingale");
let (cid, size) = hasher.finish();
assert_eq!(cid, Cid::of_raw(b"quernstone-farthingale"));
assert_eq!(size, 22);Fields§
§digest: Sha256§size: u64Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RawHasher
impl RefUnwindSafe for RawHasher
impl Send for RawHasher
impl Sync for RawHasher
impl Unpin for RawHasher
impl UnsafeUnpin for RawHasher
impl UnwindSafe for RawHasher
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