[−]Struct libp2p::multihash::Multihash
Represents a valid multihash.
Methods
impl Multihash
pub fn from_bytes(bytes: Vec<u8>) -> Result<Multihash, DecodeOwnedError>
Verifies whether bytes
contains a valid multihash, and if so returns a Multihash
.
pub fn random(hash: Hash) -> Multihash
Generates a random Multihash
from a cryptographically secure PRNG.
pub fn into_bytes(self) -> Vec<u8>
Returns the bytes representation of the multihash.
pub fn as_bytes(&self) -> &[u8]
Returns the bytes representation of this multihash.
pub fn as_ref(&self) -> MultihashRef
Builds a MultihashRef
corresponding to this Multihash
.
pub fn algorithm(&self) -> Hash
Returns which hashing algorithm is used in this multihash.
pub fn digest(&self) -> &[u8]
Returns the hashed data.
Trait Implementations
impl Hash for Multihash
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
__H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl TryFrom<Vec<u8>> for Multihash
type Error = DecodeOwnedError
The type returned in the event of a conversion error.
fn try_from(
value: Vec<u8>
) -> Result<Multihash, <Multihash as TryFrom<Vec<u8>>>::Error>
value: Vec<u8>
) -> Result<Multihash, <Multihash as TryFrom<Vec<u8>>>::Error>
impl AsRef<[u8]> for Multihash
impl Clone for Multihash
fn clone(&self) -> Multihash
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Eq for Multihash
impl Debug for Multihash
impl<'a> PartialEq<Multihash> for MultihashRef<'a>
fn eq(&self, other: &Multihash) -> bool
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<'a> PartialEq<MultihashRef<'a>> for Multihash
fn eq(&self, other: &MultihashRef<'a>) -> bool
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialEq<Multihash> for Multihash
impl TryFrom<Multihash> for PeerId
[src]
type Error = Multihash
The type returned in the event of a conversion error.
fn try_from(
value: Multihash
) -> Result<PeerId, <PeerId as TryFrom<Multihash>>::Error>
[src]
value: Multihash
) -> Result<PeerId, <PeerId as TryFrom<Multihash>>::Error>
impl PartialEq<PeerId> for Multihash
[src]
fn eq(&self, other: &PeerId) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialEq<Multihash> for PeerId
[src]
fn eq(&self, other: &Multihash) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl AsRef<Multihash> for PeerId
[src]
impl Into<Multihash> for PeerId
[src]
impl From<Multihash> for Key<Multihash>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ProtocolName for T where
T: AsRef<[u8]>,
[src]
T: AsRef<[u8]>,