pub struct PromptRegistry { /* private fields */ }Expand description
Persistent dismissed-prompt registry.
load populates from disk (returns an empty registry if the file
does not exist); mutations are in-memory until save is called.
Implementations§
Source§impl PromptRegistry
impl PromptRegistry
Sourcepub fn load(fs: &dyn Fs, path: PathBuf) -> Result<Self>
pub fn load(fs: &dyn Fs, path: PathBuf) -> Result<Self>
Load the registry from path. A missing file is treated as an
empty registry — first-run users have nothing to read.
Sourcepub fn save(&self, fs: &dyn Fs) -> Result<()>
pub fn save(&self, fs: &dyn Fs) -> Result<()>
Persist the registry to its backing path. Creates parent dirs as needed.
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Backing file path (for diagnostic messages and dodot prompts list).
Sourcepub fn is_dismissed(&self, key: &str) -> bool
pub fn is_dismissed(&self, key: &str) -> bool
True if the prompt with this key has been dismissed.
Sourcepub fn dismiss(&mut self, key: &str)
pub fn dismiss(&mut self, key: &str)
Record that the user dismissed this prompt. Idempotent — calling
twice updates dismissed_at to the latest call.
Sourcepub fn dismiss_at(&mut self, key: &str, dismissed_at: u64)
pub fn dismiss_at(&mut self, key: &str, dismissed_at: u64)
Test-friendly sibling of [dismiss] that takes an explicit
timestamp instead of reading the wall clock.
Sourcepub fn reset(&mut self, key: &str) -> bool
pub fn reset(&mut self, key: &str) -> bool
Clear a single dismissal so the prompt fires again next time.
Returns true if the key was present.
Sourcepub fn dismissed(&self) -> Vec<(&str, &PromptRecord)>
pub fn dismissed(&self) -> Vec<(&str, &PromptRecord)>
Snapshot of dismissed prompts, sorted by key. Suitable for
rendering by dodot prompts list. Allocates; if you only need
per-key lookups, prefer dismissed_at.
Sourcepub fn dismissed_at(&self, key: &str) -> Option<u64>
pub fn dismissed_at(&self, key: &str) -> Option<u64>
O(log n) lookup of a single prompt’s dismissal timestamp.
Returns None if the prompt is currently active. Pair with
is_dismissed when you only need the
boolean — this returns the timestamp too for UIs that show
“dismissed at …”.
Trait Implementations§
Source§impl Clone for PromptRegistry
impl Clone for PromptRegistry
Source§fn clone(&self) -> PromptRegistry
fn clone(&self) -> PromptRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more