[−][src]Struct multihash::MultihashRefGeneric
Represents a valid multihash.
Implementations
impl<'a, T: TryFrom<u64>> MultihashRefGeneric<'a, T>
[src]
pub fn from_slice(input: &'a [u8]) -> Result<Self, DecodeError>
[src]
Creates a new MultihashRef
from a &[u8]
.
If the input data is not a valid multihash an error is returned.
Example
use multihash::{MultihashRef, Sha2_256}; let mh = Sha2_256::digest(b"hello world"); // valid multihash let mh2 = MultihashRef::from_slice(&mh).unwrap(); // invalid multihash assert!(MultihashRef::from_slice(&vec![1, 2, 3]).is_err());
pub fn algorithm(&self) -> T
[src]
Returns the algorithm used in this multihash.
Example
use multihash::{Code, MultihashRef, Sha2_256}; let mh = Sha2_256::digest(b"hello world"); // valid multihash let mh2 = MultihashRef::from_slice(&mh).unwrap(); assert_eq!(mh2.algorithm(), Code::Sha2_256);
pub fn digest(&self) -> &'a [u8]
[src]
Returns the hash digest.
Example
use multihash::{wrap, Code, Multihash, Sha2_256}; let mh = Sha2_256::digest(b"hello world"); let digest = mh.digest(); let wrapped: Multihash = wrap(Code::Sha2_256, &digest); assert_eq!(wrapped.digest(), digest);
pub fn to_owned(&self) -> MultihashGeneric<T>
[src]
Builds a Multihash
that owns the data.
This operation allocates.
pub fn as_bytes(&self) -> &'a [u8]
[src]
Returns the bytes representation of this multihash.
Trait Implementations
impl<'a, T: Clone> Clone for MultihashRefGeneric<'a, T>
[src]
fn clone(&self) -> MultihashRefGeneric<'a, T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a, T: Copy> Copy for MultihashRefGeneric<'a, T>
[src]
impl<'a, T: Debug> Debug for MultihashRefGeneric<'a, T>
[src]
impl<'a, T: TryFrom<u64>> Deref for MultihashRefGeneric<'a, T>
[src]
impl<'a, T: Eq> Eq for MultihashRefGeneric<'a, T>
[src]
impl<'a, T: Hash> Hash for MultihashRefGeneric<'a, T>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'a, T: TryFrom<u64>> Into<Vec<u8>> for MultihashRefGeneric<'a, T>
[src]
impl<'a, T: Ord> Ord for MultihashRefGeneric<'a, T>
[src]
fn cmp(&self, other: &MultihashRefGeneric<'a, T>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'a, T: TryFrom<u64>> PartialEq<MultihashGeneric<T>> for MultihashRefGeneric<'a, T>
[src]
fn eq(&self, other: &MultihashGeneric<T>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, T: TryFrom<u64>> PartialEq<MultihashRefGeneric<'a, T>> for MultihashGeneric<T>
[src]
fn eq(&self, other: &MultihashRefGeneric<'a, T>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, T: PartialEq> PartialEq<MultihashRefGeneric<'a, T>> for MultihashRefGeneric<'a, T>
[src]
fn eq(&self, other: &MultihashRefGeneric<'a, T>) -> bool
[src]
fn ne(&self, other: &MultihashRefGeneric<'a, T>) -> bool
[src]
impl<'a, T: PartialOrd> PartialOrd<MultihashRefGeneric<'a, T>> for MultihashRefGeneric<'a, T>
[src]
fn partial_cmp(&self, other: &MultihashRefGeneric<'a, T>) -> Option<Ordering>
[src]
fn lt(&self, other: &MultihashRefGeneric<'a, T>) -> bool
[src]
fn le(&self, other: &MultihashRefGeneric<'a, T>) -> bool
[src]
fn gt(&self, other: &MultihashRefGeneric<'a, T>) -> bool
[src]
fn ge(&self, other: &MultihashRefGeneric<'a, T>) -> bool
[src]
impl<'a, T> StructuralEq for MultihashRefGeneric<'a, T>
[src]
impl<'a, T> StructuralPartialEq for MultihashRefGeneric<'a, T>
[src]
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for MultihashRefGeneric<'a, T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T> Send for MultihashRefGeneric<'a, T> where
T: Send,
T: Send,
impl<'a, T> Sync for MultihashRefGeneric<'a, T> where
T: Sync,
T: Sync,
impl<'a, T> Unpin for MultihashRefGeneric<'a, T> where
T: Unpin,
T: Unpin,
impl<'a, T> UnwindSafe for MultihashRefGeneric<'a, T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
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> 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>,