-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathdoc.rs
More file actions
29 lines (28 loc) · 957 Bytes
/
doc.rs
File metadata and controls
29 lines (28 loc) · 957 Bytes
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
//! Documentation macros.
//!
//! These are used for writing redundant documentation that shows how to use the trait-based
//! interface with a concrete crate/type.
/// Write the "Usage" section of the toplevel documentation, using the given `$aead` type in
/// code examples.
#[doc(hidden)]
#[macro_export]
#[rustfmt::skip]
macro_rules! doc_usage {
($aead:ident) => {
concat!(
"# Usage\n",
"\n",
"Simple usage (allocating, no associated data):\n",
"\n",
"```\n",
"use ", env!("CARGO_CRATE_NAME"), "::{\n",
" aead::{Aead, AeadCore, KeyInit, rand_core::OsRng},\n",
" ", stringify!($aead), ", Nonce, Key\n",
"};\n",
"\n",
"// The encryption key can be generated randomly:\n",
"let key = ", stringify!($aead), "::generate_key().expect(\"generate key\");\n",
"```\n"
)
};
}