1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright 2018 Arnau Siches
//
// Licensed under the MIT license <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to
// those terms.

//! Blot library
//!
//! **blot** computes the checksum for the given blob of data following the
//! [Objecthash] algorithm adapted to work with [Multihash] hints.
//!
//! [Objecthash]: https://github.com/benlaurie/objecthash
//! [Multihash]: https://github.com/multiformats/multihash
//!
//! blot foundation is the trait [`Blot`]. By default all Rust's primitives
//! are implemented (See [`core`]). If you need more flexibility, either implement it for your
//! types or use [`value::Value`].
//!
//! [`Blot`] requires a hashing function implementing the [`Multihash`] trait. The `default` feature
//! enables SHA1, SHA2, SHA3 and Blake2.
//!
//! # Example: primitives
//!
//! ```
//! use blot::core::Blot;
//! use blot::multihash::Sha3256;
//!
//! println!("{}", "foo".digest(Sha3256));
//! println!("{}", 1.digest(Sha3256));
//! println!("{}", vec![1, 2, 3].digest(Sha3256));
//! ```
//!
//! # Example: mixed collections
//!
//! Mixed collections require a type able to describe them consistently, like the [`value::Value`]
//! enum.
//!
//! ```
//! #[macro_use]
//! extern crate blot;
//! use blot::core::Blot;
//! use blot::multihash::Sha3256;
//! use blot::value::Value;
//!
//! fn main() {
//!     let value: Value<Sha3256> = set!{"foo", "bar", list![1, 1.0], set!{}};
//!
//!     println!("{}", value.digest(Sha3256));
//! }
//! ```

extern crate hex;
#[macro_use]
extern crate lazy_static;
extern crate regex;
extern crate serde;
extern crate serde_json;

#[cfg(feature = "blake2")]
extern crate blake2 as crypto_blake2;
#[cfg(feature = "sha-1")]
extern crate sha1 as crypto_sha1;
#[cfg(feature = "sha2")]
extern crate sha2 as crypto_sha2;
#[cfg(feature = "sha3")]
extern crate sha3 as crypto_sha3;

pub mod core;
pub mod json;
pub mod multihash;
pub mod seal;
pub mod tag;
pub mod uvar;
pub mod value;

pub use core::Blot;
pub use multihash::Multihash;