[][src]Function multihash::wrap

pub fn wrap<T: Into<u64> + TryFrom<u64>>(
    code: T,
    data: &[u8]
) -> MultihashGeneric<T>

Wraps a hash digest in Multihash with the given Mutlihash code.

The size of the hash is determoned by the size of the input hash. If it should be truncated the input data must already be the truncated hash.

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);