pub struct FixedNoClone<T>(/* private fields */);Expand description
Non-cloneable stack-allocated secret wrapper.
This is a zero-cost newtype over Fixed<T> that deliberately omits Clone and Copy.
Use this when you want to enforce single-ownership and prevent accidental duplication of secrets.
Converts from Fixed<T> via .no_clone().
§Examples
use secure_gate::{Fixed, FixedNoClone};
let secret = Fixed::new([1u8; 32]);
let no_clone: FixedNoClone<[u8; 32]> = secret.no_clone();
// no_clone cannot be cloned
assert_eq!(no_clone.expose_secret()[0], 1);With zeroize:
use secure_gate::FixedNoClone;
let mut secret = FixedNoClone::new([1u8, 2, 3]);
drop(secret); // wiped on dropImplementations§
Source§impl<T> FixedNoClone<T>
impl<T> FixedNoClone<T>
Sourcepub const fn new(value: T) -> Self
pub const fn new(value: T) -> Self
Wrap a value in a non-cloneable fixed secret.
§Example
use secure_gate::FixedNoClone;
let secret = FixedNoClone::new(42u32);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::FixedNoClone;
let secret = FixedNoClone::new([42u8; 32]);
assert_eq!(secret.expose_secret()[0], 42);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::FixedNoClone;
let mut secret = FixedNoClone::new([1u8, 2, 3]);
secret.expose_secret_mut()[0] = 99;
assert_eq!(secret.expose_secret()[0], 99);Source§impl<T: Zeroize> FixedNoClone<T>
impl<T: Zeroize> FixedNoClone<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::FixedNoClone;
let mut key = FixedNoClone::new([42u8; 32]);
// ... use key ...
key.zeroize_now(); // Explicit wipe - makes intent clearTrait Implementations§
Source§impl<T> Debug for FixedNoClone<T>
impl<T> Debug for FixedNoClone<T>
Source§impl<T: Zeroize> Zeroize for FixedNoClone<T>
Available on crate feature zeroize only.
impl<T: Zeroize> Zeroize for FixedNoClone<T>
Available on crate feature
zeroize only.impl<T: Zeroize> ZeroizeOnDrop for FixedNoClone<T>
Available on crate feature
zeroize only.Auto Trait Implementations§
impl<T> Freeze for FixedNoClone<T>where
T: Freeze,
impl<T> RefUnwindSafe for FixedNoClone<T>where
T: RefUnwindSafe,
impl<T> Send for FixedNoClone<T>where
T: Send,
impl<T> Sync for FixedNoClone<T>where
T: Sync,
impl<T> Unpin for FixedNoClone<T>where
T: Unpin,
impl<T> UnwindSafe for FixedNoClone<T>where
T: UnwindSafe,
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