[]Trait ipfs_embed_core::MultihashDigest

pub trait MultihashDigest: 'static + Clone + Eq + Send + Sync + Debug {
    fn new(code: u64, input: &[u8]) -> Result<Self, Error>;
fn wrap(code: u64, digest: &[u8]) -> Result<Self, Error>;
fn code(&self) -> u64;
fn size(&self) -> u8;
fn digest(&self) -> &[u8];
fn read<R>(r: R) -> Result<Self, Error>
    where
        R: Read
; fn from_bytes(bytes: &[u8]) -> Result<Self, Error> { ... }
fn write<W>(&self, w: W) -> Result<(), Error>
    where
        W: Write
, { ... }
fn to_bytes(&self) -> Vec<u8> { ... }
fn to_raw(&self) -> Result<RawMultihash, Error> { ... } }

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>(r: R) -> Result<Self, Error> where
    R: Read

Reads a multihash from a byte stream.

Loading content...

Provided methods

fn from_bytes(bytes: &[u8]) -> Result<Self, 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.

fn write<W>(&self, w: W) -> Result<(), Error> where
    W: Write

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.

Loading content...

Implementations on Foreign Types

impl MultihashDigest for Multihash

Loading content...

Implementors

Loading content...