Type Alias libp2p::multihash::MultihashGeneric
source · pub type MultihashGeneric<const N: usize> = Multihash<N>;
👎Deprecated since 0.18.0: Use `multihash::Multihash instead.
Expand description
Deprecated type-alias for the Multihash
type.
Aliased Type§
struct MultihashGeneric<const N: usize> { /* private fields */ }
Implementations
source§impl<const S: usize> Multihash<S>
impl<const S: usize> Multihash<S>
sourcepub const fn wrap(code: u64, input_digest: &[u8]) -> Result<Multihash<S>, Error>
pub const fn wrap(code: u64, input_digest: &[u8]) -> Result<Multihash<S>, Error>
Wraps the digest in a multihash.
sourcepub fn from_bytes(bytes: &[u8]) -> Result<Multihash<S>, Error>
pub fn from_bytes(bytes: &[u8]) -> Result<Multihash<S>, Error>
Parses a multihash from a bytes.
You need to make sure the passed in bytes have the correct length. The digest length
needs to match the size
value of the multihash.
sourcepub fn write<W>(&self, w: W) -> Result<usize, Error>where
W: Write,
pub fn write<W>(&self, w: W) -> Result<usize, Error>where
W: Write,
Writes a multihash to a byte stream, returning the written size.
sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Returns the length in bytes needed to encode this multihash into bytes.
sourcepub fn truncate(&self, size: u8) -> Multihash<S>
pub fn truncate(&self, size: u8) -> Multihash<S>
Truncates the multihash to the given size. It’s up to the caller to ensure that the new size is secure (cryptographically) to use.
If the new size is larger than the current size, this method does nothing.
Trait Implementations
source§impl<const S: usize> Ord for Multihash<S>
impl<const S: usize> Ord for Multihash<S>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<const A: usize, const B: usize> PartialEq<Multihash<B>> for Multihash<A>
impl<const A: usize, const B: usize> PartialEq<Multihash<B>> for Multihash<A>
source§impl<const S: usize> PartialOrd for Multihash<S>
impl<const S: usize> PartialOrd for Multihash<S>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more