pub struct ForgettingMemory { /* private fields */ }Expand description
A decaying, file-backed memory store.
Implementations§
Source§impl ForgettingMemory
impl ForgettingMemory
Sourcepub fn new(
files: FileMemoryStore,
config: ForgetConfig,
) -> Result<Self, FileMemoryError>
pub fn new( files: FileMemoryStore, config: ForgetConfig, ) -> Result<Self, FileMemoryError>
Opens the store root and loads any existing decay ledger.
Sourcepub fn config(&self) -> ForgetConfig
pub fn config(&self) -> ForgetConfig
Current decay policy.
Sourcepub fn remember(
&mut self,
name: &str,
content: &str,
importance: f64,
now: SystemTime,
) -> Result<(), FileMemoryError>
pub fn remember( &mut self, name: &str, content: &str, importance: f64, now: SystemTime, ) -> Result<(), FileMemoryError>
Writes a new memory with the given importance. Re-remembering an existing name overwrites its content and refreshes its timestamps.
Sourcepub fn recall(
&mut self,
name: &str,
now: SystemTime,
) -> Result<String, FileMemoryError>
pub fn recall( &mut self, name: &str, now: SystemTime, ) -> Result<String, FileMemoryError>
Reads a memory’s content, refreshing its last_access_at (recency reward).
Sourcepub fn importance(&self, name: &str) -> Option<f64>
pub fn importance(&self, name: &str) -> Option<f64>
Importance of a memory, if tracked.
Sourcepub fn forget(&mut self, name: &str) -> Result<(), FileMemoryError>
pub fn forget(&mut self, name: &str) -> Result<(), FileMemoryError>
Explicitly forgets one memory and its ledger entry.
Sourcepub fn should_forget(&self, name: &str, now: SystemTime) -> bool
pub fn should_forget(&self, name: &str, now: SystemTime) -> bool
Whether name should be pruned at now: either TTL-expired or weak-and-idle-grace.
Sourcepub fn consolidate(&mut self, now: SystemTime) -> Result<usize, FileMemoryError>
pub fn consolidate(&mut self, now: SystemTime) -> Result<usize, FileMemoryError>
Prunes every memory that should be forgotten at now. Returns the number pruned.
Pure with respect to time (uses the injected now); the caller decides when to run it.
Sourcepub fn live_at(&self, now: SystemTime) -> Vec<String>
pub fn live_at(&self, now: SystemTime) -> Vec<String>
Names of memories that currently survive should_forget at now.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ForgettingMemory
impl RefUnwindSafe for ForgettingMemory
impl Send for ForgettingMemory
impl Sync for ForgettingMemory
impl Unpin for ForgettingMemory
impl UnsafeUnpin for ForgettingMemory
impl UnwindSafe for ForgettingMemory
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