pub struct EphemeralVault<T: Zeroize> { /* private fields */ }Expand description
A time-limited and read-limited vault for sensitive data.
EphemeralVault provides automatic expiration and read counting for secrets.
The inner value is zeroized when the vault is dropped.
§Security Note
The secret remains in memory until the vault is dropped, even after TTL expires
or reads are exhausted. Use revoke to explicitly zeroize early.
Implementations§
Source§impl<T: Zeroize> EphemeralVault<T>
impl<T: Zeroize> EphemeralVault<T>
Sourcepub fn new(inner: T, ttl: Duration, max_reads: usize) -> Self
pub fn new(inner: T, ttl: Duration, max_reads: usize) -> Self
Create a new vault with the given TTL and maximum read count.
Sourcepub fn get(&self) -> Option<&T>
pub fn get(&self) -> Option<&T>
Access the secret if still valid (not expired, not exhausted, not revoked). Each successful call decrements the remaining read count.
Sourcepub fn remaining_reads(&self) -> usize
pub fn remaining_reads(&self) -> usize
Remaining reads before exhaustion.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Returns true if TTL has elapsed.
Sourcepub fn is_revoked(&self) -> bool
pub fn is_revoked(&self) -> bool
Returns true if the secret has been revoked (zeroized early).
Sourcepub fn time_remaining(&self) -> Duration
pub fn time_remaining(&self) -> Duration
Time remaining until expiration.
Trait Implementations§
Source§impl<T: Zeroize> Drop for EphemeralVault<T>
impl<T: Zeroize> Drop for EphemeralVault<T>
impl<T: Zeroize> ZeroizeOnDrop for EphemeralVault<T>
Auto Trait Implementations§
impl<T> !Freeze for EphemeralVault<T>
impl<T> !RefUnwindSafe for EphemeralVault<T>
impl<T> !Sync for EphemeralVault<T>
impl<T> Forget for EphemeralVault<T>
impl<T> Move for EphemeralVault<T>
impl<T> Send for EphemeralVault<T>
impl<T> Unpin for EphemeralVault<T>
impl<T> UnsafeUnpin for EphemeralVault<T>where
Option<T>: UnsafeUnpin,
impl<T> UnwindSafe for EphemeralVault<T>where
Option<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