Skip to main content

MemoryStore

Struct MemoryStore 

Source
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

Strictly import a .lino memory document, rejecting malformed input.

Strictly replace current memory from a .lino document.

Return the doublet-reducible projection of every memory event.

Source§

impl MemoryStore

Source

pub const fn new() -> Self

Source

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.

Source

pub fn append(&mut self, event: MemoryEvent)

Source

pub fn import(&mut self, other: &[MemoryEvent]) -> usize

Append every event from other to this store. Returns the number of events appended.

Source

pub fn purge_deleted_conversations(&mut self) -> usize

Permanently remove all events that belong to conversations already marked with a conversation_deleted event.

Source

pub fn purge_conversation(&mut self, conversation_id: &str) -> usize

Permanently remove all events attributed to a single conversation id.

Source

pub fn reset(&mut self) -> usize

Clear every dynamic memory event while keeping the static seed intact.

Source

pub fn events(&self) -> &[MemoryEvent]

Source

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.

Source

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.

Source

pub const fn len(&self) -> usize

Source

pub const fn is_empty(&self) -> bool

Render the entire memory log as a portable demo_memory Links Notation document.

Parse a demo_memory document and replace the store’s contents.

Append every event parsed from a demo_memory document. Returns the number of events appended.

Source

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.

Source

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

Source§

fn clone(&self) -> MemoryStore

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MemoryStore

Source§

fn default() -> MemoryStore

Returns the “default value” for a type. Read more
Source§

impl LinkStore for MemoryStore

Source§

fn backend(&self) -> LinkStoreBackend

Returns the active physical backend.
Source§

fn append_memory_event( &mut self, event: MemoryEvent, ) -> Result<String, LinkStoreError>

Append a memory event and return the stable record id assigned to it.
Strictly import a .lino memory or bundle document.
Export the current memory projection as Links Notation.
Source§

fn records(&self) -> Vec<LinkRecord>

Return every stored record as doublet-reducible metadata.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more