numext_fixed_hash_core/
lib.rs

1// Copyright 2018-2019 Cryptape Technologies LLC.
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9//! This is a internal crate used by [numext-fixed-hash].
10//!
11//! **Notice:
12//! You should NOT use this crate directly.
13//! Please use [numext-fixed-hash] instead of this crate.**
14//!
15//! [numext-fixed-hash]: https://docs.rs/numext-fixed-hash
16
17extern crate constructor;
18
19use thiserror::Error;
20
21#[macro_use]
22mod tools;
23
24constructor::construct_fixed_hashes!(
25    H128 {
26        size = 128,
27    },
28    H160 {
29        size = 160,
30    },
31    H224 {
32        size = 224,
33    },
34    H256 {
35        size = 256,
36    },
37    H384 {
38        size = 384,
39    },
40    H512 {
41        size = 512,
42    },
43    H520 {
44        size = 520,
45    },
46    H1024 {
47        size = 1024,
48    },
49    H2048 {
50        size = 2048,
51    },
52    H4096 {
53        size = 4096,
54    },
55);
56
57#[cfg(feature = "bits_128")]
58convert_between!(U128, H128, 16);
59#[cfg(feature = "bits_160")]
60convert_between!(U160, H160, 20);
61#[cfg(feature = "bits_224")]
62convert_between!(U224, H224, 28);
63#[cfg(feature = "bits_256")]
64convert_between!(U256, H256, 32);
65#[cfg(feature = "bits_384")]
66convert_between!(U384, H384, 48);
67#[cfg(feature = "bits_512")]
68convert_between!(U512, H512, 64);
69#[cfg(feature = "bits_520")]
70convert_between!(U520, H520, 65);
71#[cfg(feature = "bits_1024")]
72convert_between!(U1024, H1024, 128);
73#[cfg(feature = "bits_2048")]
74convert_between!(U2048, H2048, 256);
75#[cfg(feature = "bits_4096")]
76convert_between!(U4096, H4096, 512);