tiny_multihash/
lib.rs

1//! Multihash implementation.
2//!
3//! Feature Flags
4//! -------------
5//!
6//! Multihash has lots of [feature flags], by default, all features (except for `test`) are
7//! enabled.
8//!
9//! Some of them are about specific hash functions, these are:
10//!
11//!  - `blake2b`: Enable Blake2b hashers
12//!  - `blake2s`: Enable Blake2s hashers
13//!  - `sha1`: Enable SHA-1 hashers
14//!  - `sha2`: Enable SHA-2 hashers
15//!  - `sha3`: Enable SHA-3 hashers
16//!  - `strobe`: Enable Strobe hashers
17//!
18//! In order to enable all hashers, you can set the `all` feature flag.
19//!
20//! The library has support for `no_std`, if you disable the `std` feature flag.
21//!
22//! The `multihash-impl` feature flag enables a default Multihash implementation that contains all
23//! bundled hashers (which may be disabled via the feature flags mentioned above). If only want a
24//! specific subset of hash algorithms or add one which isn't supporte by default, you will likely
25//! disable that feature and enable `derive` in order to be able to use the [`Multihash` derive].
26//!
27//! The `test` feature flag enables property based testing features.
28//!
29//! [feature flags]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section
30//! [`Multihash` derive]: crate::derive
31
32#![deny(missing_docs)]
33#![cfg_attr(not(feature = "std"), no_std)]
34
35#[cfg(any(test, feature = "test"))]
36mod arb;
37mod error;
38mod hasher;
39mod hasher_impl;
40mod multihash;
41#[cfg(feature = "multihash-impl")]
42mod multihash_impl;
43
44pub use crate::error::{Error, Result};
45#[cfg(feature = "std")]
46pub use crate::hasher::WriteHasher;
47pub use crate::hasher::{Digest, Hasher, Size, StatefulHasher};
48pub use crate::multihash::{Multihash, MultihashCode};
49pub use generic_array::typenum::{self, U128, U16, U20, U28, U32, U48, U64};
50#[cfg(feature = "derive")]
51pub use tiny_multihash_derive as derive;
52
53#[cfg(feature = "multihash-impl")]
54pub use crate::multihash_impl::Code;
55
56#[cfg(feature = "blake2b")]
57pub use crate::hasher_impl::blake2b::{Blake2b256, Blake2b512, Blake2bDigest, Blake2bHasher};
58#[cfg(feature = "blake2s")]
59pub use crate::hasher_impl::blake2s::{Blake2s128, Blake2s256, Blake2sDigest, Blake2sHasher};
60#[cfg(feature = "blake3")]
61pub use crate::hasher_impl::blake3::{Blake3Digest, Blake3Hasher, Blake3_256};
62pub use crate::hasher_impl::identity::{Identity256, IdentityDigest, IdentityHasher};
63#[cfg(feature = "sha1")]
64pub use crate::hasher_impl::sha1::{Sha1, Sha1Digest};
65#[cfg(feature = "sha2")]
66pub use crate::hasher_impl::sha2::{Sha2Digest, Sha2_256, Sha2_512};
67#[cfg(feature = "sha3")]
68pub use crate::hasher_impl::sha3::{Keccak224, Keccak256, Keccak384, Keccak512, KeccakDigest};
69#[cfg(feature = "sha3")]
70pub use crate::hasher_impl::sha3::{Sha3Digest, Sha3_224, Sha3_256, Sha3_384, Sha3_512};
71#[cfg(feature = "strobe")]
72pub use crate::hasher_impl::strobe::{Strobe256, Strobe512, StrobeDigest, StrobeHasher};
73pub use crate::hasher_impl::unknown::UnknownDigest;