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.
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) -> T
pub fn into_inner(self) -> T
Consume and return the inner value.
Trait 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