multi-hash 1.0.3

Multihash self-describing cryptographic hash data
docs.rs failed to build multi-hash-1.0.3
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

Multihash

Multiformats Multihash implementation without constant size in the type signature.

Features

  • Uses the [multiutil::BaseEncoded] smart pointers to wrap the Multihash into EncodecMultihash for base encoded multihashes; automating the encoding/decoding to/from strings and byte slices.
  • Serde support to/from human readable and binary formats.
  • Supports raw binary encoding and decoding using [Into<Vec<u8>>] and [TryFrom<&[u8]>] trait implementations.

Examples

Bulding a multihash from some bytes:

let mh = Builder::new_from_bytes(Codec::Sha3384, b"for great justice, move every zig!")?
    .try_build()?;

Building a base encoded multihash from some bytes:

let encoded_mh = Builder::new_from_bytes(Codec::Sha3256, b"for great justice, move every zig!")?
    .with_base_encoding(Base::Base58Btc)
    .try_build_encoded()?;

Existing multihash objects can be converted to [crate::mh::EncodedMultihash] objects by using .into():

let mh = Builder::new_from_bytes(Codec::Sha3384, b"for great justice, move every zig!")?
    .try_build()?;

// this will use the preferred encoding for multihash objects: Base::Base16Lower
let encoded_mh1: EncodedMultihash = mh.into();

// or you can chose the base enccoding...
let encoded_mh2: EncodedMultihash::new(Base::Base32Upper, mh);