pub struct RecentsStore {
buffer: VecDeque<RecentLocation>,
cap: usize,
pub path: PathBuf,
}Expand description
Ring buffer (cap 50) of recent locations.
De-duplicates consecutive identical (profile_id, bucket, prefix) triples
so rapid re-navigation to the same folder does not pollute the list.
Persisted as ${app_config_dir}/recents.json.
Fields§
§buffer: VecDeque<RecentLocation>§cap: usizeMaximum number of entries. Kept as a field so tests can override.
path: PathBufImplementations§
Source§impl RecentsStore
impl RecentsStore
const DEFAULT_CAP: usize = 50
pub fn new(path: PathBuf) -> Self
Sourcepub fn load(path: PathBuf) -> Self
pub fn load(path: PathBuf) -> Self
Load from path. Returns an empty store if the file does not exist.
fn clamp(&mut self)
Sourcepub fn track(&mut self, profile_id: ProfileId, bucket: BucketId, prefix: String)
pub fn track(&mut self, profile_id: ProfileId, bucket: BucketId, prefix: String)
Record a navigation. De-duplicates consecutive identical locations (same profile, bucket, prefix). Evicts the oldest entry when at cap.
Sourcepub fn list(&self) -> Vec<RecentLocation>
pub fn list(&self) -> Vec<RecentLocation>
Return all recent locations (newest first).
Sourcepub fn flush(&self) -> Result<(), AppError>
pub fn flush(&self) -> Result<(), AppError>
Flush to disk atomically (tmp + rename).
Returns AppError::Internal on serialization, mkdir, write, or rename
failure so callers (e.g. recents_clear) can surface the failure to
the user. Previously this used let _ = ... everywhere and silently
dropped failures, which meant a “Clear recents” click could leave the
stale on-disk list intact and reappear on the next launch.
Auto Trait Implementations§
impl Freeze for RecentsStore
impl RefUnwindSafe for RecentsStore
impl Send for RecentsStore
impl Sync for RecentsStore
impl Unpin for RecentsStore
impl UnsafeUnpin for RecentsStore
impl UnwindSafe for RecentsStore
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more