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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
//! This crate provides shared macros to:
//!
//! - faillable clone structs
//! - create an ockam node and access its `Context`
//! - write some node-related tests
//!
//! Procedural macros for use with Ockam.
use TokenStream;
use quote;
use ;
/// Implements the [`TryClone`](https://docs.rs/ockam_core/latest/ockam_core/traits/trait.TryClone.html) trait for a type.
///
/// The macro supports the following attributes:
///
/// - `#[try_clone(crate = "...")]`: specify a path to the crate that
/// will be used to import the items required by the macro. This can be
/// helpful when using the macro from an internal `ockam` crate. Defaults
/// to `ockam`.
///
/// Example of use:
///
/// ```ignore
/// #[derive(ockam::TryClone)]
/// #[try_clone(crate = "ockam")]
/// pub struct MyStruct {
/// a: u32,
/// }
/// ```
/// Implements the [`Message`](https://docs.rs/ockam_core/latest/ockam_core/trait.Message.html) trait for a type.
///
/// Example of use:
///
/// ```ignore
/// #[derive(ockam::Message, Deserialize, Serialize)]
/// pub struct MyStruct {
/// a: u32,
/// }
///
/// impl Encodable for MyStruct {
/// fn encode(&self) -> Result<Encoded>{
/// serialize(self)
/// }
/// }
/// impl Decodable for MyStruct {
/// fn decode(e: &[u8]) -> Result<MyStruct> {
/// deserialize(e)
/// }
/// }
/// ```
/// Marks an async function to be run in an ockam node.
///
/// The `#[node]` macro transform an async input main function into a regular
/// output main function that sets up an ockam node and executes the body of
/// the input function inside the node.
///
/// The macro supports the following attributes:
///
/// - `#[ockam::node(crate = "...")]`: specify a path to the crate that will be
/// used to import the items required by the macro. This can be helpful
/// when using the macro from an internal `ockam` crate. Defaults to
/// `ockam`.
///
/// - #[ockam::node(no_main)]: by default, this macro executes the provided
/// function within the standard entry point function `main`. If your target
/// device doesn't support this entry point, use this argument to execute the
/// input function within your own entry point as a separate function.
///
/// Example of use:
///
/// ```ignore
/// #[ockam::node]
/// async fn main(mut ctx: ockam::Context) -> ockam::Result<()> {
/// ctx.shutdown_node().await
/// }
/// ```
/// Marks an async test function to be run in an ockam node.
///
/// It transforms an async input function into a test output function that sets
/// up an ockam node and executes the body of the input function inside the
/// node.
///
/// The macro supports the following attributes:
///
/// - `#[ockam::test(crate = "...")]`: specify a path to the crate that will be
/// used to import the items required by the macro. This can be helpful
/// when using the macro from an internal `ockam` crate. Defaults to
/// `ockam_node`.
///
/// - `#[ockam::test(timeout = 1000)]`: the macro executes the test with a
/// timeout interval (in milliseconds) to avoid blocking the test
/// indefinitely. If the test times out it will panic. Defaults to 30000 (30
/// seconds).
///
/// Example of use:
///
/// ```ignore
/// #[ockam::test]
/// async fn main(ctx: &mut ockam::Context) -> ockam::Result<()> {
/// ctx.shutdown_node().await
/// }
/// ```
/// Expands to a test suite for a custom implementation of the vault traits.
///
/// The name of the test function must match one of the test functions
/// accompanying the traits definitions in the `ockam_vault::traits` module.
///
/// Example of use:
///
/// ```ignore
/// use ockam_vault::Vault;
///
/// fn new_vault() -> Vault {
/// Vault::default()
/// }
///
/// #[ockam_macros::vault_test]
/// fn hkdf() {}
/// ```