multihash/
lib.rs

1//! Bare-minimum multihash data structure.
2//!
3//! This crate defines a `no_std` compatible data structures for representing a `Multihash`.
4//!
5//! It does not offer any hashing, instead you are encouraged to either do the hashing yourself.
6//! Alternatively, you can use an existing code table or make your own code table.
7//!
8//! The [`multihash-codetable`] crate defines a set of hashes to get started quickly.
9//! To make your own codetable, use the [`multihash-derive`] crate.
10//!
11//! The `arb` feature flag enables the quickcheck arbitrary implementation for property based
12//! testing.
13//!
14//! For serializing the multihash there is support for [Serde] via the `serde-codec` feature and
15//! the [SCALE Codec] via the `scale-codec` feature.
16//!
17//! [Serde]: https://serde.rs
18//! [SCALE Codec]: https://github.com/paritytech/parity-scale-codec
19//! [`multihash-derive`]: https://docs.rs/multihash-derive
20//! [`multihash-codetable`]: https://docs.rs/multihash-codetable
21
22#![deny(missing_docs, unsafe_code)]
23#![cfg_attr(not(feature = "std"), no_std)]
24
25#[cfg(feature = "alloc")]
26extern crate alloc;
27
28#[cfg(feature = "arb")]
29mod arb;
30mod error;
31mod multihash;
32#[cfg(not(feature = "std"))]
33pub mod no_std_io; // Make it public for downstream crates(e.g. `cid`).
34#[cfg(feature = "serde")]
35mod serde;
36
37/// Multihash result.
38#[deprecated(note = "Use `Result<T, multihash::Error>` instead")]
39pub type Result<T> = core::result::Result<T, Error>;
40
41pub use crate::error::Error;
42pub use crate::multihash::Multihash;
43
44/// Deprecated type-alias for the [`Multihash`] type.
45#[deprecated(since = "0.18.0", note = "Use `multihash::Multihash instead.")]
46pub type MultihashGeneric<const N: usize> = Multihash<N>;