pub struct SessionStore { /* private fields */ }Expand description
Session store — holds in-memory state and manages file persistence.
Implementations§
Source§impl SessionStore
impl SessionStore
Sourcepub fn new(source_file: &str) -> Self
pub fn new(source_file: &str) -> Self
Create a new session store. Loads existing persistent data if present.
Sourcepub fn remember(&mut self, key: &str, value: &str, source_step: &str)
pub fn remember(&mut self, key: &str, value: &str, source_step: &str)
Store a value in ephemeral memory.
Sourcepub fn recall(&self, key: &str) -> Option<&MemoryEntry>
pub fn recall(&self, key: &str) -> Option<&MemoryEntry>
Recall a value from ephemeral memory. Returns None if not found.
Sourcepub fn memory_entries(&self) -> Vec<&MemoryEntry>
pub fn memory_entries(&self) -> Vec<&MemoryEntry>
List all ephemeral memory entries.
Sourcepub fn persist(&mut self, key: &str, value: &str, source_step: &str)
pub fn persist(&mut self, key: &str, value: &str, source_step: &str)
Persist a value to the file-backed store.
Sourcepub fn retrieve(&self, key: &str) -> Option<&MemoryEntry>
pub fn retrieve(&self, key: &str) -> Option<&MemoryEntry>
Retrieve a value from the file-backed store.
Sourcepub fn retrieve_query(&self, query: &str) -> Vec<&MemoryEntry>
pub fn retrieve_query(&self, query: &str) -> Vec<&MemoryEntry>
Retrieve all entries matching a simple query (substring match on key or value).
Sourcepub fn mutate(&mut self, key: &str, new_value: &str, source_step: &str) -> bool
pub fn mutate(&mut self, key: &str, new_value: &str, source_step: &str) -> bool
Mutate (update) an existing entry in the store. Returns true if the key existed and was updated.
Sourcepub fn purge(&mut self, key: &str) -> bool
pub fn purge(&mut self, key: &str) -> bool
Purge (delete) an entry from the store. Returns true if the key existed and was removed.
Sourcepub fn purge_query(&mut self, query: &str) -> usize
pub fn purge_query(&mut self, query: &str) -> usize
Purge all entries matching a query (substring match). Returns the number of entries removed.
Sourcepub fn store_count(&self) -> usize
pub fn store_count(&self) -> usize
Number of entries in the persistent store.
Sourcepub fn memory_count(&self) -> usize
pub fn memory_count(&self) -> usize
Number of entries in ephemeral memory.
Sourcepub fn store_path(&self) -> &Path
pub fn store_path(&self) -> &Path
Path to the store file (for display).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SessionStore
impl RefUnwindSafe for SessionStore
impl Send for SessionStore
impl Sync for SessionStore
impl Unpin for SessionStore
impl UnsafeUnpin for SessionStore
impl UnwindSafe for SessionStore
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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