pub struct Dynamic<T: ?Sized>(pub Box<T>);Expand description
A zero-cost, heap-allocated wrapper for sensitive data.
See module docs for full examples.
Tuple Fields§
§0: Box<T>Implementations§
Source§impl<T: ?Sized> Dynamic<T>
impl<T: ?Sized> Dynamic<T>
Sourcepub fn expose_secret(&self) -> &T
pub fn expose_secret(&self) -> &T
Access the secret value immutably.
§Examples
use secure_gate::Dynamic;
let pw: Dynamic<String> = "secret".into();
assert_eq!(pw.expose_secret(), "secret");pub fn expose_secret_mut(&mut self) -> &mut T
pub fn into_inner(self) -> Box<T>
Trait Implementations§
Source§impl From<&str> for Dynamic<String>
Convenience: &str → password secret.
impl From<&str> for Dynamic<String>
Convenience: &str → password secret.
use secure_gate::Dynamic;
let pw: Dynamic<String> = "correct horse battery staple".into();
assert_eq!(&*pw, "correct horse battery staple");Source§impl<T: ?Sized + Zeroize> From<Dynamic<T>> for DynamicZeroizing<T>
Available on crate feature zeroize only.
impl<T: ?Sized + Zeroize> From<Dynamic<T>> for DynamicZeroizing<T>
Available on crate feature
zeroize only.Source§impl<T> From<T> for Dynamic<T>where
T: Sized,
Convert any owned value into a heap secret.
impl<T> From<T> for Dynamic<T>where
T: Sized,
Convert any owned value into a heap secret.
§Examples
use secure_gate::Dynamic;
let pw: Dynamic<String> = "hunter2".into();
let data: Dynamic<Vec<u8>> = vec![1, 2, 3].into();
assert_eq!(&*pw, "hunter2");
assert_eq!(data.expose_secret(), &[1, 2, 3]);Source§impl<T: Zeroize + DefaultIsZeroes> Zeroize for Dynamic<T>
Available on crate feature zeroize only.
impl<T: Zeroize + DefaultIsZeroes> Zeroize for Dynamic<T>
Available on crate feature
zeroize only.impl<T: ?Sized + Zeroize> ZeroizeOnDrop for Dynamic<T>
Available on crate feature
zeroize only.Auto Trait Implementations§
impl<T> Freeze for Dynamic<T>where
T: ?Sized,
impl<T> RefUnwindSafe for Dynamic<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for Dynamic<T>
impl<T> Sync for Dynamic<T>
impl<T> Unpin for Dynamic<T>where
T: ?Sized,
impl<T> UnwindSafe for Dynamic<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