pub enum HashAlgorithm {
Sha1(Sha1),
Sha256(Sha256),
Blake3(Box<Hasher>),
}Expand description
A streaming hasher abstraction over the supported HashKinds.
This is the crate’s digest factory (GC-02): callers obtain a hasher through
HashAlgorithm::new_for_kind (explicit repository kind) or
HashAlgorithm::new (thread-local compatibility default) instead of
matching on the algorithm themselves. The remaining direct SHA dispatch in
internal/pack/utils.rs and internal/pack/wrapper.rs is migrated onto
this type in B3-03. It implements std::io::Write so it can be used as a
sink while streaming.
Variants§
Sha1(Sha1)
Sha256(Sha256)
Blake3(Box<Hasher>)
BLAKE3-256 (git-internal / Libra extension; 32-byte output). Boxed because the BLAKE3 hasher state is much larger than the SHA states.
Implementations§
Source§impl HashAlgorithm
impl HashAlgorithm
Sourcepub fn new_for_kind(kind: HashKind) -> Self
pub fn new_for_kind(kind: HashKind) -> Self
Create a new streaming hasher for an explicit kind.
Does not consult the thread-local HashKind; use this on worker
threads, async tasks and any code that may serve a repository other
than the one configured on the current thread.
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new hash algorithm instance based on the current thread-local hash kind.
Compatibility wrapper around HashAlgorithm::new_for_kind.
Sourcepub fn finalize_object_hash(self) -> ObjectHash
pub fn finalize_object_hash(self) -> ObjectHash
Finalize into an ObjectHash of the hasher’s own kind.
The kind is taken from the hasher itself, so this is correct on any
thread and is the preferred replacement for
ObjectHash::from_bytes(&hasher.finalize()) and for the deprecated
length-inferring ObjectHash::from_bytes_infer_kind helper.
Trait Implementations§
Source§impl Clone for HashAlgorithm
impl Clone for HashAlgorithm
Source§impl Default for HashAlgorithm
impl Default for HashAlgorithm
Source§impl Write for HashAlgorithm
impl Write for HashAlgorithm
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)Auto Trait Implementations§
impl Freeze for HashAlgorithm
impl RefUnwindSafe for HashAlgorithm
impl Send for HashAlgorithm
impl Sync for HashAlgorithm
impl Unpin for HashAlgorithm
impl UnsafeUnpin for HashAlgorithm
impl UnwindSafe for HashAlgorithm
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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> ⓘ
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.