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
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) DUSK NETWORK. All rights reserved.
//! 
//! [](https://github.com/dusk-network/code-hasher)
//! [](https://docs.rs/code-hasher/)
//! # code-hasher
//!
//! Tiny proc macro library designed to hash a code block generating a unique
//! identifier for it which will get written into a `const` inside of the code
//! block.
//!
//! ## Example
//! ```rust
//! #[code_hasher::hash(SOME_CONST_NAME, version = "0.1.0")]
//! pub mod testing_module {
//!
//! pub fn this_does_something() -> [u8; 32] {
//! SOME_CONST_NAME
//! }
//! }
//! ```
//!
//! Here, `SOME_CONST_NAME` has assigned as value the resulting hash of:
//! - The code contained inside `testing_module`.
//! - The version passed by the user (is optional). Not adding it will basically
//! not hash this attribute and **WILL NOT** use any default alternatives.
//!
//! ## Licensing
//! This code is licensed under Mozilla Public License Version 2.0 (MPL-2.0).
//! Please see [LICENSE](https://github.com/dusk-network/rusk/tree/master/macros/code-hasher/LICENSE) for further info.
use Hasher;
use TokenStream;