pub struct DynamicNoClone<T: ?Sized>(/* private fields */);Expand description
Non-cloneable heap-allocated secret wrapper.
This is a thin newtype over Dynamic<T> that deliberately omits Clone.
Use this for dynamic secrets where duplication must be prevented.
Converts from Dynamic<T> via .no_clone().
§Examples
use secure_gate::{Dynamic, DynamicNoClone};
let secret = Dynamic::new("hunter2".to_string());
let no_clone: DynamicNoClone<String> = secret.no_clone();
// no_clone cannot be cloned
assert_eq!(no_clone.expose_secret(), "hunter2");Implementations§
Source§impl<T: ?Sized> DynamicNoClone<T>
impl<T: ?Sized> DynamicNoClone<T>
Sourcepub fn new(value: Box<T>) -> Self
pub fn new(value: Box<T>) -> Self
Wrap a boxed value in a non-cloneable dynamic secret.
§Example
use secure_gate::DynamicNoClone;
let boxed = Box::new("secret".to_string());
let no_clone = DynamicNoClone::new(boxed);Sourcepub const fn expose_secret(&self) -> &T
pub const fn expose_secret(&self) -> &T
Expose the inner value for read-only access.
This is the only way to read the secret — loud and auditable.
§Example
use secure_gate::DynamicNoClone;
let secret = DynamicNoClone::new(Box::new("hunter2".to_string()));
assert_eq!(secret.expose_secret(), "hunter2");Sourcepub fn expose_secret_mut(&mut self) -> &mut T
pub fn expose_secret_mut(&mut self) -> &mut T
Expose the inner value for mutable access.
This is the only way to mutate the secret — loud and auditable.
§Example
use secure_gate::DynamicNoClone;
let mut secret = DynamicNoClone::new(Box::new("hello".to_string()));
secret.expose_secret_mut().push_str(" world");
assert_eq!(secret.expose_secret(), "hello world");Source§impl<T: ?Sized + Zeroize> DynamicNoClone<T>
impl<T: ?Sized + Zeroize> DynamicNoClone<T>
Sourcepub fn zeroize_now(&mut self)
pub fn zeroize_now(&mut self)
Explicitly zeroize the secret immediately.
This is useful when you want to wipe memory before the value goes out of scope, or when you want to make the zeroization intent explicit in the code.
§Example
use secure_gate::DynamicNoClone;
let mut password = DynamicNoClone::new(Box::new("secret".to_string()));
// ... use password ...
password.zeroize_now(); // Explicit wipe - makes intent clearSource§impl DynamicNoClone<String>
impl DynamicNoClone<String>
Trait Implementations§
Source§impl<T: ?Sized> Debug for DynamicNoClone<T>
impl<T: ?Sized> Debug for DynamicNoClone<T>
Source§impl<T: ?Sized + Zeroize> Zeroize for DynamicNoClone<T>
Available on crate feature zeroize only.
impl<T: ?Sized + Zeroize> Zeroize for DynamicNoClone<T>
Available on crate feature
zeroize only.impl<T: ?Sized + Zeroize> ZeroizeOnDrop for DynamicNoClone<T>
Available on crate feature
zeroize only.Auto Trait Implementations§
impl<T> Freeze for DynamicNoClone<T>where
T: ?Sized,
impl<T> RefUnwindSafe for DynamicNoClone<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for DynamicNoClone<T>
impl<T> Sync for DynamicNoClone<T>
impl<T> Unpin for DynamicNoClone<T>where
T: ?Sized,
impl<T> UnwindSafe for DynamicNoClone<T>where
T: UnwindSafe + ?Sized,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more