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
/// Creates a type alias for [`Dynamic<T>`](crate::Dynamic).
///
/// Generates a named, optionally-documented type alias. The generated type inherits
/// all `Dynamic<T>` methods including `expose_secret()`, `with_secret()`, `to_hex()`, etc.
///
/// *Requires feature `alloc`.*
///
/// # Syntax
///
/// ```text
/// dynamic_alias!(pub Name, T); // public, auto-generated doc
/// dynamic_alias!(pub(crate) Name, T); // crate-visible
/// dynamic_alias!(Name, T); // private
/// dynamic_alias!(pub Name, T, "doc string"); // with custom doc
/// ```
///
/// # Examples
///
/// All three visibility forms:
///
/// ```rust
/// use secure_gate::{dynamic_alias, RevealSecret};
///
/// dynamic_alias!(pub Password, String); // public
/// dynamic_alias!(pub(crate) SessionToken, Vec<u8>); // crate-visible
/// dynamic_alias!(private_key_bytes, Vec<u8>); // private
///
/// let pw: Password = "hunter2".into();
/// pw.with_secret(|s| assert!(!s.is_empty()));
/// ```
///
/// With a custom doc string:
///
/// ```rust
/// use secure_gate::{dynamic_alias, RevealSecret};
///
/// dynamic_alias!(pub Token, Vec<u8>, "OAuth 2.0 bearer token.");
/// let token: Token = vec![1u8, 2, 3].into();
/// assert_eq!(token.expose_secret(), &[1, 2, 3]);
/// ```
///
/// # Implementation Notes
///
/// `dynamic_alias!` has **no zero-size or type-level guard** — any `T` is accepted.
/// Macro-generated aliases lack runtime size checks beyond what `Dynamic<T>` itself provides.
/// Note that unlike `fixed_alias!`, this macro (and the generic dynamic variant) allows zero-sized or empty inner types with no compile-time rejection.
/// Validate expected inner types and sizes in unit tests:
///
/// ```rust
/// use secure_gate::dynamic_alias;
///
/// dynamic_alias!(pub ApiToken, Vec<u8>);
/// // In your tests: assert!(token.len() > 0);
/// ```
///
/// # Security
///
/// Generated aliases inherit all [`Dynamic`](crate::Dynamic) security guarantees: zeroize
/// on drop (including spare capacity), redacted `Debug`, explicit access only.
///
/// # See also
///
/// - [`dynamic_generic_alias!`](crate::dynamic_generic_alias) — when the inner type varies
/// - [`fixed_alias!`](crate::fixed_alias) — stack-allocated alternative