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.
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.
Sourcepub fn into_inner(self) -> Box<T>
pub fn into_inner(self) -> Box<T>
Consume and return the inner Box<T>.
Source§impl DynamicNoClone<String>
impl DynamicNoClone<String>
Sourcepub fn finish_mut(&mut self) -> &mut String
pub fn finish_mut(&mut self) -> &mut String
Get a mutable reference and shrink spare capacity.
Similar to Dynamic::finish_mut().
Source§impl<T> DynamicNoClone<Vec<T>>
impl<T> DynamicNoClone<Vec<T>>
Sourcepub fn finish_mut(&mut self) -> &mut Vec<T>
pub fn finish_mut(&mut self) -> &mut Vec<T>
Get a mutable reference and shrink spare capacity.
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