pub type CloneableArray<const N: usize> = Fixed<CloneableArrayInner<N>>;Expand description
A fixed-size array of bytes wrapped as a cloneable secret.
This type provides a secure wrapper around a [u8; N] array that can be safely cloned
while ensuring the underlying data is properly zeroized when no longer needed.
Use this for cryptographic keys, nonces, or other fixed-size secret data.
§Examples
use secure_gate::{CloneableArray, ExposeSecret};
// Create from an array
let key: CloneableArray<32> = [42u8; 32].into();
// Access the inner array
let inner = &key.expose_secret().0;
assert_eq!(inner.len(), 32);Aliased Type§
pub struct CloneableArray<const N: usize>(/* private fields */);Implementations§
Source§impl<const N: usize> CloneableArray<N>
impl<const N: usize> CloneableArray<N>
Sourcepub fn init_with<F>(constructor: F) -> Self
pub fn init_with<F>(constructor: F) -> Self
Construct a cloneable array secret by building it in a closure.
Same stack-minimization benefits as CloneableString::init_with.
§Example
use secure_gate::CloneableArray;
let key = CloneableArray::<32>::init_with(|| {
let mut arr = [0u8; 32];
// Fill from some source...
arr
});Sourcepub fn try_init_with<F, E>(constructor: F) -> Result<Self, E>
pub fn try_init_with<F, E>(constructor: F) -> Result<Self, E>
Fallible version of init_with.
Same stack-minimization benefits as init_with, but allows for construction
that may fail with an error. Useful when reading secrets from fallible sources
like files or network connections.