pub enum ObjectHasher {
Sha1(Hasher),
Sha256(Sha256),
}Expand description
Incremental hasher for Git’s supported object-id algorithms.
Variants§
Sha1(Hasher)
SHA-1 (20-byte digests) with sha1dc collision detection.
Sha256(Sha256)
SHA-256 (32-byte digests).
Implementations§
Source§impl ObjectHasher
impl ObjectHasher
Sourcepub fn algo(self: &ObjectHasher) -> HashAlgo
pub fn algo(self: &ObjectHasher) -> HashAlgo
The hash algorithm this hasher produces.
Sourcepub fn for_object(algo: HashAlgo, kind: ObjectKind, len: u64) -> Self
pub fn for_object(algo: HashAlgo, kind: ObjectKind, len: u64) -> Self
Create a hasher that already consumed the Git object header for kind and len.
The header is written into a stack buffer (no heap allocation).
Sourcepub fn finalize(self) -> Result<ObjectId>
pub fn finalize(self) -> Result<ObjectId>
Finish hashing and return the object id.
§Errors
Returns Error::HashCollision when sha1dc detects a chosen-prefix collision.
Sourcepub fn finalize_into(self, out: &mut [u8]) -> Result<usize>
pub fn finalize_into(self, out: &mut [u8]) -> Result<usize>
Write the raw digest into out and return the number of bytes written.
§Errors
Returns Error::InvalidObjectId when out is shorter than the digest
length for this algorithm (a diagnostic string names the required size).
Trait Implementations§
Source§impl Clone for ObjectHasher
impl Clone for ObjectHasher
Source§impl Debug for ObjectHasher
impl Debug for ObjectHasher
Source§impl Write for ObjectHasher
impl Write for ObjectHasher
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flushes this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations§
impl Freeze for ObjectHasher
impl RefUnwindSafe for ObjectHasher
impl Send for ObjectHasher
impl Sync for ObjectHasher
impl Unpin for ObjectHasher
impl UnsafeUnpin for ObjectHasher
impl UnwindSafe for ObjectHasher
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