pub struct MemoryStore { /* private fields */ }Expand description
Memory log for dynamic events. Normal writes append records; explicit purge and reset methods exist for irreversible user-requested cleanup.
Implementations§
Source§impl MemoryStore
impl MemoryStore
Sourcepub fn try_import_links_notation(
&mut self,
text: &str,
) -> Result<usize, LinkStoreError>
pub fn try_import_links_notation( &mut self, text: &str, ) -> Result<usize, LinkStoreError>
Strictly import a .lino memory document, rejecting malformed input.
Sourcepub fn try_replace_from_links_notation(
&mut self,
text: &str,
) -> Result<(), LinkStoreError>
pub fn try_replace_from_links_notation( &mut self, text: &str, ) -> Result<(), LinkStoreError>
Strictly replace current memory from a .lino document.
Sourcepub fn link_records(&self) -> Vec<LinkRecord>
pub fn link_records(&self) -> Vec<LinkRecord>
Return the doublet-reducible projection of every memory event.
Source§impl MemoryStore
impl MemoryStore
pub const fn new() -> Self
Sourcepub fn from_events(events: Vec<MemoryEvent>) -> Self
pub fn from_events(events: Vec<MemoryEvent>) -> Self
Build a store from an existing list. Useful for tests and for the
from_links_notation factory below.
pub fn append(&mut self, event: MemoryEvent)
Sourcepub fn import(&mut self, other: &[MemoryEvent]) -> usize
pub fn import(&mut self, other: &[MemoryEvent]) -> usize
Append every event from other to this store. Returns the number of
events appended.
Sourcepub fn purge_deleted_conversations(&mut self) -> usize
pub fn purge_deleted_conversations(&mut self) -> usize
Permanently remove all events that belong to conversations already
marked with a conversation_deleted event.
Sourcepub fn purge_conversation(&mut self, conversation_id: &str) -> usize
pub fn purge_conversation(&mut self, conversation_id: &str) -> usize
Permanently remove all events attributed to a single conversation id.
Sourcepub fn reset(&mut self) -> usize
pub fn reset(&mut self) -> usize
Clear every dynamic memory event while keeping the static seed intact.
pub fn events(&self) -> &[MemoryEvent]
Sourcepub fn record_access(&mut self, indices: &[usize]) -> usize
pub fn record_access(&mut self, indices: &[usize]) -> usize
Count one read access on each event at indices (issue #494: usage is
counted on access, not inferred from citations alone). Out-of-range
indices are ignored. Returns how many events were actually counted.
Sourcepub fn apply_substitution(&mut self, old: &str, new: &str) -> usize
pub fn apply_substitution(&mut self, old: &str, new: &str) -> usize
Rewrite every textual field of every stored event, replacing each
occurrence of old with new. This is the write half of the
natural-language substitution primitive (issue #529): a recall reads the
associative memory, a substitution transforms it in place — together they
give the user full, link-cli-style read+write control over memory through
ordinary language.
Returns the total number of textual occurrences replaced across the
store. Structural keys are never touched: only the value-bearing fields
(content, inputs, outputs, conversation_title, demo_label) and
free-form evidence entries are rewritten, so a substitution can never
corrupt the document shape.
pub const fn len(&self) -> usize
pub const fn is_empty(&self) -> bool
Sourcepub fn export_links_notation(&self) -> String
pub fn export_links_notation(&self) -> String
Render the entire memory log as a portable demo_memory Links
Notation document.
Sourcepub fn replace_from_links_notation(&mut self, text: &str)
pub fn replace_from_links_notation(&mut self, text: &str)
Parse a demo_memory document and replace the store’s contents.
Sourcepub fn import_links_notation(&mut self, text: &str) -> usize
pub fn import_links_notation(&mut self, text: &str) -> usize
Append every event parsed from a demo_memory document. Returns the
number of events appended.
Sourcepub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self>
Load events from a file on disk. Missing file yields an empty store.
Sourcepub fn save_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn save_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
Persist the full store back to a file on disk. Creates parent
directories as needed. The write is atomic (temp file + rename) and
serialized against other writers via an advisory lock — see
write_locked_atomic.
Trait Implementations§
Source§impl Clone for MemoryStore
impl Clone for MemoryStore
Source§fn clone(&self) -> MemoryStore
fn clone(&self) -> MemoryStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MemoryStore
impl Debug for MemoryStore
Source§impl Default for MemoryStore
impl Default for MemoryStore
Source§fn default() -> MemoryStore
fn default() -> MemoryStore
Source§impl LinkStore for MemoryStore
impl LinkStore for MemoryStore
Source§fn backend(&self) -> LinkStoreBackend
fn backend(&self) -> LinkStoreBackend
Source§fn append_memory_event(
&mut self,
event: MemoryEvent,
) -> Result<String, LinkStoreError>
fn append_memory_event( &mut self, event: MemoryEvent, ) -> Result<String, LinkStoreError>
Source§fn import_memory_links_notation(
&mut self,
text: &str,
) -> Result<usize, LinkStoreError>
fn import_memory_links_notation( &mut self, text: &str, ) -> Result<usize, LinkStoreError>
.lino memory or bundle document.