Skip to main content

Store

Struct Store 

Source
pub struct Store { /* private fields */ }

Implementations§

Source§

impl Store

Source

pub fn write_event( &self, action: &str, key: &str, scope: &str, tokens: i32, ) -> Result<()>

Write an event to the live activity feed. action: “save” | “search” | “inject” | “hit” key: memory key, query string, or count description scope: scope path tokens: tokens injected (non-zero only for “inject” action)

Source

pub fn recent_events(&self, limit: i32) -> Result<Vec<EventLogEntry>>

Return the N most recent events, newest first.

Source

pub fn events_today_summary(&self) -> Result<(i64, i64, i64, i64)>

Counts for today: (saves, injections, searches, tokens_injected).

Source

pub fn purge_old_events(&self, days: u32) -> Result<u64>

Purge events older than days days. Called by the maintenance scheduler.

Source§

impl Store

Source

pub fn save(&self, params: SaveParams) -> Result<SaveAction>

Source

pub fn get(&self, id: i64) -> Result<Memory>

Source

pub fn search(&self, params: SearchParams) -> Result<Vec<SearchResult>>

Source

pub fn delete_scope(&self, scope: &str, hard: bool) -> Result<usize>

Source

pub fn delete(&self, key: &str, scope: Option<&str>, hard: bool) -> Result<bool>

Source

pub fn delete_by_id(&self, id: i64, hard: bool) -> Result<bool>

Source

pub fn update( &self, id: i64, key: Option<&str>, value: Option<&str>, tags: Option<Vec<String>>, ) -> Result<Memory>

Source

pub fn list( &self, scope: Option<&str>, source_type: Option<&SourceType>, limit: Option<i32>, ) -> Result<Vec<Memory>>

Source

pub fn list_all( &self, scope: Option<&str>, source_type: Option<&SourceType>, ) -> Result<Vec<Memory>>

Source

pub fn context( &self, scope: Option<&str>, limit: Option<i32>, ) -> Result<Vec<Memory>>

Source

pub fn apply_confidence_decay(&self) -> Result<u32>

Source

pub fn search_by_tags( &self, tags: &[&str], scope: Option<&str>, limit: i32, ) -> Result<Vec<SearchResult>>

Source

pub fn purge_soft_deleted(&self, retention_days: u32) -> Result<u32>

Hard-delete soft-deleted memories older than retention_days days. Returns the number of rows deleted.

Source

pub fn vacuum(&self) -> Result<()>

Run VACUUM and record the timestamp in _metadata.

Source

pub fn distinct_scopes(&self) -> Result<Vec<String>>

Return sorted distinct scopes of non-deleted memories.

Source

pub fn maintenance_status(&self) -> Result<MaintenanceStatus>

Return a snapshot of maintenance-relevant statistics.

Source

pub fn list_by_source_commit(&self) -> Result<Vec<Memory>>

Source§

impl Store

Source

pub fn record_injection( &self, memory_ids: &[i64], tokens_per_memory: i32, ) -> Result<()>

Source

pub fn record_hit(&self, memory_id: i64) -> Result<()>

Source

pub fn record_hit_batch(&self, memory_ids: &[i64]) -> Result<()>

Source

pub fn cumulative_stats(&self) -> Result<TokenStats>

Cumulative token stats across all time (from the metrics table).

Source

pub fn dedup_total(&self) -> Result<i64>

Source

pub fn revision_total(&self) -> Result<i64>

Source

pub fn low_roi_count(&self) -> Result<i64>

Source

pub fn get_metrics(&self) -> Result<Vec<MemoryMetric>>

Source§

impl Store

Source

pub fn add_relation( &self, source_id: i64, target_id: i64, rel_type: RelationType, ) -> Result<i64>

Source

pub fn get_relations(&self, memory_id: i64) -> Result<Vec<Relation>>

Source

pub fn superseded_ids(&self) -> Result<HashSet<i64>>

Source§

impl Store

Source

pub fn open( path: &str, config: Config, passphrase: Option<&str>, ) -> Result<Self>

Source

pub fn open_in_memory() -> Result<Self>

Source

pub fn open_in_memory_with_config(config: Config) -> Result<Self>

Source

pub fn config(&self) -> &Config

Source

pub fn get_metadata(&self, key: &str) -> Result<Option<String>>

Source

pub fn set_metadata(&self, key: &str, value: &str) -> Result<()>

Source

pub fn schema_version(&self) -> Result<i64>

Source

pub fn is_encrypted(path: &str) -> bool

Check if a database file is encrypted (requires encryption feature to detect).

Auto Trait Implementations§

§

impl !Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl Send for Store

§

impl !Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

§

impl UnwindSafe for Store

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> 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, 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.