[−][src]Trait tiny_multihash::MultihashDigest
Trait for reading and writhing Multihashes.
It is usually derived from a list of hashers by the Multihash
derive.
Required methods
fn new(code: u64, input: &[u8]) -> Result<Self, Error>
Returns the hash of the input.
fn wrap(code: u64, digest: &[u8]) -> Result<Self, Error>
Wraps the digest in a multihash.
fn code(&self) -> u64
Returns the code of the multihash.
fn size(&self) -> u8
Returns the actual size of the digest, that will be returned by digest()
.
fn digest(&self) -> &[u8]
Returns the digest.
fn read<R: Read>(r: R) -> Result<Self, Error> where
Self: Sized,
Self: Sized,
Reads a multihash from a byte stream.
Provided methods
fn from_bytes(bytes: &[u8]) -> Result<Self, Error> where
Self: Sized,
Self: Sized,
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.
fn write<W: Write>(&self, w: W) -> Result<(), Error>
Writes a multihash to a byte stream.
fn to_bytes(&self) -> Vec<u8>
Returns the bytes of a multihash.
fn to_raw(&self) -> Result<RawMultihash, Error>
Returns the RawMultihash.