Function sc_network::multiaddr::multihash::wrap [−][src]
pub fn wrap<T>(code: T, data: &[u8]) -> MultihashGeneric<T> where
T: Into<u64> + TryFrom<u64>,
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);