Skip to main content

MemoryStore

Trait MemoryStore 

Source
pub trait MemoryStore:
    Send
    + Sync
    + Debug {
    // Required methods
    fn put<'life0, 'life1, 'async_trait>(
        &'life0 self,
        record: &'life1 MemoryRecord,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        memory_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<MemoryRecord>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn all<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryRecord>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn remove<'life0, 'life1, 'async_trait>(
        &'life0 self,
        memory_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn query<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 MemoryQuery,
        now: DateTime<Utc>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryRecord>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

A governed memory store. The two server backends (JSON files, Postgres) implement it over their own layouts; InMemoryMemoryStore is the dev/test implementation, the same role InMemoryCheckpointer plays for checkpoints.

The contract deliberately knows nothing about tenants: tenant isolation is the server’s {tenant}/ id-namespacing, applied by the server backends around this contract — a store that can see another tenant’s records is a breach wearing a storage costume.

Required Methods§

Source

fn put<'life0, 'life1, 'async_trait>( &'life0 self, record: &'life1 MemoryRecord, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store record under its content address. Idempotent: storing the same record twice yields false (already present) and at most one stored record — the Effect::Idempotent write converges by construction, since the address is derived from content plus provenance.

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, memory_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<MemoryRecord>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch one record by content address (None when absent).

Source

fn all<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryRecord>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The query universe: every record in the namespace. Retrieval semantics live in apply_query; dev-scale stores scan, and larger backends pre-filter on columns before applying the same function.

Source

fn remove<'life0, 'life1, 'async_trait>( &'life0 self, memory_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove memory_id from the store (false when absent). Forgetting (R0.8 wave 2) is real deletion of derived state — journals are hash-chained evidence and are never touched (open question 4’s boundary).

Provided Methods§

Source

fn query<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 MemoryQuery, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryRecord>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The records matching query, expiry evaluated at now. The default implementation scans via MemoryStore::all and applies apply_query; backends with column-mapped storage override the scan, never the semantics.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§