pub struct ContentHashCache { /* private fields */ }Expand description
An owned SHA-256 result cache with a byte capacity chosen by its caller.
Implementations§
Source§impl ContentHashCache
impl ContentHashCache
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Creates an empty cache retaining at most capacity input bytes.
Sourcepub fn hash(&self, bytes: &[u8]) -> String
pub fn hash(&self, bytes: &[u8]) -> String
Returns the lowercase hexadecimal SHA-256 of all bytes.
A cached digest is reused only for an exactly equal byte buffer. Oversized inputs and an unavailable cache are hashed directly.
Sourcepub fn cached_bytes(&self) -> Option<usize>
pub fn cached_bytes(&self) -> Option<usize>
Returns the actual input bytes retained, or None if the cache is unavailable.
Auto Trait Implementations§
impl !Freeze for ContentHashCache
impl RefUnwindSafe for ContentHashCache
impl Send for ContentHashCache
impl Sync for ContentHashCache
impl Unpin for ContentHashCache
impl UnsafeUnpin for ContentHashCache
impl UnwindSafe for ContentHashCache
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