[−][src]Struct iprs::multihash::Multihash
Type adapts several hashing algorithms within multihash specification.
Implementations
impl Multihash
[src]
pub fn new(codec: Multicodec, data: &[u8]) -> Result<Multihash>
[src]
Create a Multihash instance, of type multi-codec for data. Digest
will be created for data
, using the multi-hash algorithm specified
by codec
.
pub fn from_digest(codec: Multicodec, digest: &[u8]) -> Result<Multihash>
[src]
New multihash from digest and multihash-type.
pub fn decode_lazy(data: &[u8]) -> Result<Multihash>
[src]
Create a lazy instance of multihash from data
, where data contains
encoded multihash. Call Self::parse method to de-serialize.
pub fn parse(&mut self) -> Result<()>
[src]
Lazy parse. Typically called after creating this instance using Self::decode_lazy constructor.
pub fn decode(buf: &[u8]) -> Result<(Multihash, &[u8])>
[src]
Decode a hash-digest that was encoded using multi-format specification.
- The
type
is an unsigned variable integer identifying the hash function. There is a default table, and it is configurable. The default table is the [multicodec table]. - The
length
is an unsigned variable integer counting the length of the digest, in bytes. - The
value
is the hash function digest, with a length of exactly <digest-length>
bytes.
Return the Multihash value and remaining byte-slice. Caller can use Self::to_codec, Self::to_digest, Self::unwrap methods to get the hash-digest and hash-algorithm used to generate the digest.
pub fn encode(&self) -> Result<Vec<u8>>
[src]
Encode hash-digest and associated headers as per multi-hash specification.
<hash-func-type><digest-length><digest-value>
impl Multihash
[src]
pub fn to_codec(&self) -> Result<Multicodec>
[src]
Return the multihash codec.
pub fn to_digest(&self) -> Result<Vec<u8>>
[src]
Return the underlying hash digest.
Panic if digest is not generated or decoded.
pub fn unwrap(self) -> Result<(Multicodec, Vec<u8>)>
[src]
Unwrap the underlying codec and hash digest. Panic if digest is not generated or decoded.
Trait Implementations
impl Clone for Multihash
[src]
impl Display for Multihash
[src]
impl Eq for Multihash
[src]
impl From<Multihash> for PeerId
[src]
impl From<PeerId> for Multihash
[src]
impl PartialEq<Multihash> for Multihash
[src]
impl StructuralEq for Multihash
[src]
impl StructuralPartialEq for Multihash
[src]
impl Write for Multihash
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
1.36.0[src]
fn is_write_vectored(&self) -> bool
[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
[src]
fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl RefUnwindSafe for Multihash
impl Send for Multihash
impl Sync for Multihash
impl Unpin for Multihash
impl UnwindSafe for Multihash
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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,