pub type CloneableVec = Dynamic<CloneableVecInner>;Expand description
A dynamically-sized vector of bytes wrapped as a cloneable secret.
This type provides a secure wrapper around a Vec<u8> that can be safely cloned
while ensuring the underlying data is properly zeroized when no longer needed.
Use this for variable-length secret data like encrypted payloads or keys.
§Examples
use secure_gate::CloneableVec;
// Create from a vector
let data: CloneableVec = vec![1, 2, 3, 4].into();
// Create from a slice
let data2: CloneableVec = b"hello world".as_slice().into();
// Access the inner vector
let inner = data.expose_inner();
assert_eq!(inner.len(), 4);Aliased Type§
pub struct CloneableVec(/* private fields */);Implementations§
Source§impl CloneableVec
impl CloneableVec
Sourcepub const fn expose_inner(&self) -> &Vec<u8> ⓘ
pub const fn expose_inner(&self) -> &Vec<u8> ⓘ
Returns a reference to the inner vector without cloning.
This method provides direct access to the wrapped Vec<u8>.
The reference is valid for the lifetime of the CloneableVec.
Sourcepub fn expose_inner_mut(&mut self) -> &mut Vec<u8> ⓘ
pub fn expose_inner_mut(&mut self) -> &mut Vec<u8> ⓘ
Returns a mutable reference to the inner vector.
This method provides direct mutable access to the wrapped Vec<u8>.
Use this when you need to modify the vector contents in-place.
Sourcepub fn init_with<F>(constructor: F) -> Self
pub fn init_with<F>(constructor: F) -> Self
Construct a cloneable vec secret by building it in a closure.
Same stack-minimization benefits as CloneableString::init_with.
§Example
use secure_gate::CloneableVec;
let seed = CloneableVec::init_with(|| {
let mut v = vec![0u8; 32];
// Fill from some source...
v
});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.
Trait Implementations§
Source§impl From<&[u8]> for CloneableVec
Wrap a byte slice in a CloneableVec.
impl From<&[u8]> for CloneableVec
Wrap a byte slice in a CloneableVec.