pub struct NonceStore { /* private fields */ }Expand description
A store for confirmation nonces with TTL-based expiration.
Nonces are 8-character hex strings that gate dangerous operations.
They remain valid until their TTL expires — not consumed on validation —
making operations idempotent: a retried rm --confirm=abc123 bigdir/
works if the nonce hasn’t expired.
Implementations§
Source§impl NonceStore
impl NonceStore
Sourcepub fn lookup(&self, nonce: &str) -> Result<NonceScope, String>
pub fn lookup(&self, nonce: &str) -> Result<NonceScope, String>
Look up a nonce’s scope without validating against a command/path.
Returns the scope if the nonce exists and hasn’t expired, or an error. Useful for embedders building custom confirmation UIs.
Sourcepub fn issue(&self, command: &str, paths: &[&str]) -> String
pub fn issue(&self, command: &str, paths: &[&str]) -> String
Issue a new nonce for the given command and paths.
Returns an 8-character hex string. Opportunistically GCs expired nonces.
Sourcepub fn validate(
&self,
nonce: &str,
command: &str,
paths: &[&str],
) -> Result<(), String>
pub fn validate( &self, nonce: &str, command: &str, paths: &[&str], ) -> Result<(), String>
Validate a nonce against a command and paths.
Checks that the nonce exists, hasn’t expired, the command matches, and the confirmed paths are a subset of the authorized paths.
Does NOT consume the nonce — it stays valid until TTL expires.
Trait Implementations§
Source§impl Clone for NonceStore
impl Clone for NonceStore
Source§fn clone(&self) -> NonceStore
fn clone(&self) -> NonceStore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more