Skip to main content

Database

Struct Database 

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

Implementations§

Source§

impl Database

Source

pub fn log_consolidation( &self, id: &str, action: &str, memory_ids: &[String], reason: Option<&str>, performed_by: &str, timestamp: &str, ) -> Result<(), StorageError>

Source

pub fn mark_judged( &self, memory_id: &str, timestamp: &str, ) -> Result<(), StorageError>

Source

pub fn get_pending_judgments( &self, limit: usize, ) -> Result<Vec<String>, StorageError>

Source§

impl Database

Source

pub fn open(path: &str) -> Result<Self, StorageError>

Open or create database at the given path.

Source

pub fn open_read_only(path: &str) -> Result<Self, StorageError>

Open an existing database in read-only mode.

Skips schema application: the caller must ensure the schema already exists (a read-only connection cannot run CREATE TABLE or set PRAGMA journal_mode). Intended for defense-in-depth scenarios where the source database must not be mutated (e.g. engram migrate).

Source

pub fn in_memory() -> Result<Self, StorageError>

Create an in-memory database (for testing).

Source

pub fn connection(&self) -> &Connection

Source§

impl Database

Source

pub fn search_fts( &self, query: &str, limit: usize, ) -> Result<Vec<FtsResult>, StorageError>

Source§

impl Database

Source

pub fn insert_memory(&self, memory: &Memory) -> Result<(), StorageError>

Source

pub fn get_memory(&self, id: &str) -> Result<Memory, StorageError>

Source

pub fn set_memory_indexed( &self, id: &str, indexed: bool, ) -> Result<(), StorageError>

Source

pub fn set_memory_embeddings( &self, id: &str, embedding_context: &[u8], embedding_action: &[u8], embedding_result: &[u8], ) -> Result<(), StorageError>

Source

pub fn set_memory_score(&self, id: &str, score: f32) -> Result<(), StorageError>

Source

pub fn touch_memory( &self, id: &str, timestamp: &str, ) -> Result<(), StorageError>

Source

pub fn set_superseded_by( &self, id: &str, superseded_by: &str, ) -> Result<(), StorageError>

Source

pub fn delete_memory(&self, id: &str) -> Result<(), StorageError>

Source

pub fn bulk_insert_memories( &self, memories: &[Memory], ) -> Result<usize, StorageError>

Source

pub fn list_all_memories(&self) -> Result<Vec<Memory>, StorageError>

Source

pub fn get_unindexed_memories( &self, limit: usize, ) -> Result<Vec<Memory>, StorageError>

Source

pub fn get_indexed_memory_ids(&self) -> Result<Vec<String>, StorageError>

Source§

impl Database

Source

pub fn upsert_q_value( &self, level: &str, state: &str, action: &str, value: f32, timestamp: &str, ) -> Result<(), StorageError>

Source

pub fn get_q_value( &self, level: &str, state: &str, action: &str, ) -> Result<f32, StorageError>

Source

pub fn load_q_table( &self, level: &str, ) -> Result<Vec<(String, String, f32, u32)>, StorageError>

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