macro_rules! dynamic_generic_alias {
($vis:vis $name:ident, $doc:literal) => { ... };
($vis:vis $name:ident) => { ... };
}Expand description
Creates a generic type alias Name<T> for Dynamic<T>.
Useful when you need a single reusable name for heap-allocated secrets of varying types.
Requires feature alloc.
§Syntax
dynamic_generic_alias!(pub Name, "doc string"); // public with custom doc
dynamic_generic_alias!(pub(crate) Name); // crate-visible, auto-generated doc§Examples
use secure_gate::{dynamic_generic_alias, RevealSecret};
dynamic_generic_alias!(pub SecureBox, "Generic heap-allocated secret wrapper.");
let key: SecureBox<Vec<u8>> = vec![0u8; 32].into();
key.with_secret(|b| assert_eq!(b.len(), 32));§Implementation Notes
Macro-generated generic aliases lack runtime size checks. Validate expected
inner types and sizes in unit tests. As with dynamic_alias!, zero-sized or
empty inner types are permitted; validate non-zero size in tests.
The inner type T must implement Zeroize — this is enforced by Dynamic<T>,
not the macro.
§See also
dynamic_alias!— preferred when the inner type is knownfixed_generic_alias!— stack-allocated alternative