Skip to main content

Algorithm

Enum Algorithm 

Source
pub enum Algorithm {
    Sha1,
    Sha256,
    Sha512,
    Blake3,
    Md5,
    XxHash64,
    FastCdc,
    Perceptual,
    Unknown,
}
Expand description

The hash functions this workspace can produce, so an index record can say what it was computed with.

The as_str / from_str pair is the stable wire form: these strings appear in on-disk records and must not change without a format version bump.

Variants§

§

Sha1

SHA-1. 20-byte digests.

§

Sha256

SHA-2 with a 256-bit state. 32-byte digests.

§

Sha512

SHA-2 with a 512-bit state. 64-byte digests.

§

Blake3

BLAKE3 with the default 32-byte output.

§

Md5

MD5. 16-byte digests.

§

XxHash64

xxHash64. 8-byte digests.

§

FastCdc

FastCDC content-defined chunking. 4-byte digests: the 32-bit Gear fingerprint at the cut point, the width the FastCDC reference implementation produces.

§

Perceptual

A perceptual hash. The width is a property of the modality (image, audio, video, text), so output_len is None.

§

Unknown

A name written by a future version of this kit. A record carrying it can still be read; it just cannot be recomputed here.

Implementations§

Source§

impl Algorithm

Source

pub fn as_str(&self) -> &'static str

The stable wire form, e.g. "sha256".

Source

pub fn from_str(s: &str) -> Self

Parses the wire form. An unrecognised string yields Algorithm::Unknown, never an error, so records written by a future version stay readable. Matching is exact and case-sensitive: "SHA256" is Unknown.

Source

pub fn output_len(&self) -> Option<usize>

Digest width in bytes for the fixed-width members; None for Perceptual, whose width is a property of the modality, and for Unknown.

Trait Implementations§

Source§

impl Clone for Algorithm

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Algorithm

Source§

impl Debug for Algorithm

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Algorithm

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Algorithm

Source§

impl PartialEq for Algorithm

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Algorithm

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.