Skip to main content

Digest

Enum Digest 

#[non_exhaustive]
pub enum Digest { Sha256, Sha384, Sha512, Sha1, }
Expand description

The algorithm a PeerId is made with: the <alg> of its <alg>:<hash> text.

Sha256 is the id of a peer by default. The others exist so a pin written elsewhere can be read; whether a method accepts them is its own allow-list (a list of Digest values). MD5 is not supported at all. Methods whose keys are named by another algorithm add variants here, which is why the enum is non-exhaustive.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Sha256

SHA-256, 32 bytes. The default and the only digest of an identity.

§

Sha384

SHA-384, 48 bytes.

§

Sha512

SHA-512, 64 bytes.

§

Sha1

SHA-1, 20 bytes. Legacy interoperability only.

Implementations§

§

impl Digest

pub const fn name(self) -> &'static str

The lowercase name used in text: sha256, sha384, sha512, sha1.

pub const fn size(self) -> usize

The digest length in bytes.

pub fn of(self, data: &[u8]) -> PeerId

The id of data under this algorithm: what a method hashes is its public key, or the encoding of its certificate.

Trait Implementations§

§

impl Clone for Digest

§

fn clone(&self) -> Digest

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
§

impl Copy for Digest

§

impl Debug for Digest

§

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

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for Digest

Available on crate feature serde only.
§

fn deserialize<D>( deserializer: D, ) -> Result<Digest, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl Display for Digest

§

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

Formats the value using the given formatter. Read more
§

impl Eq for Digest

§

impl FromStr for Digest

§

type Err = Error

The associated error which can be returned from parsing.
§

fn from_str(value: &str) -> Result<Digest, <Digest as FromStr>::Err>

Parses a string s to return a value of this type. Read more
§

impl Hash for Digest

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl Leaf for Digest

§

const TYPE: &'static str = "Digest"

The name a Datum shows: bool, u16, Duration, or the type’s own.
§

fn labels() -> &'static [(&'static str, &'static str)]

A label for each fixed text the type names, as (text, label): what a form shows beside the text. Only the texts that have a label are listed.
§

fn to_text(&self) -> String

The text of the value.
§

fn from_text(__text: &str) -> Result<Digest, LeafError>

The value a text stands for. Read more
§

fn choices() -> Option<&'static [&'static str]>

The texts a unit-only enum accepts.
§

const ORDERED: bool = false

The type declares an order (order answers Some).
§

fn same(a: &Self, b: &Self) -> bool

Whether two values are the same setting. Settings are compared after both texts are parsed into this type, never as the raw input: by default the canonical texts of the two values are equal, which the round-trip contract makes the type’s own equality. A type whose equal values can write different texts (-0.0 and 0.0) overrides it.
§

fn order(_a: &Self, _b: &Self) -> Option<Ordering>

The order of two values, where the type has one.
§

impl Ord for Digest

§

fn cmp(&self, other: &Digest) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
§

impl PartialEq for Digest

§

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

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

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

Inequality operator !=. Read more
§

impl PartialOrd for Digest

§

fn partial_cmp(&self, other: &Digest) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl Serialize for Digest

Available on crate feature serde only.
§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl StructuralPartialEq for Digest

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

impl<T> Describe for T
where T: Leaf,

§

const LEAF: bool = true

The type is one text: a [Leaf], or an untagged enum whose arms all are. An untagged enum counts the arms that are not, and holds at most one.
§

type Fill = LeafSlot<T>

The partly filled state of this type: what Partial holds.
§

fn description() -> Description

What this type is.
§

const OPTIONAL: bool = false

The type is Option<_>: leaving a field of it out is a value of its own, so it is never required.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Inspect for T
where T: Leaf,

§

fn at(&self, at: &[Segment]) -> Option<Datum>

The leaf at at, or None.
§

fn entries(&self, _at: &[Segment]) -> Option<Entries>

The structure at at, or None.
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> Same for T

Source§

type Output = T

Should always be Self
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.