Skip to main content

MemoryStore

Trait MemoryStore 

Source
pub trait MemoryStore:
    Clone
    + Send
    + Sync
    + 'static {
    // Required methods
    fn scan(
        &self,
        query: &str,
        limit: usize,
    ) -> impl Future<Output = Result<MemoryScan, MemoryError>> + Send;
    fn read(
        &self,
        ids: &[i64],
        keys: &[MemoryKey],
    ) -> impl Future<Output = Result<Vec<MemoryRecord>, MemoryError>> + Send;
    fn list(
        &self,
    ) -> impl Future<Output = Result<Vec<MemoryRecord>, MemoryError>> + Send;
    fn put(
        &self,
        content: &str,
        replacement: Option<MemoryKey>,
    ) -> impl Future<Output = Result<MemoryRecord, MemoryError>> + Send;
    fn delete(
        &self,
        key: MemoryKey,
    ) -> impl Future<Output = Result<(), MemoryError>> + Send;
    fn sync(
        &self,
        memories: &[MemoryRecord],
    ) -> impl Future<Output = Result<SyncReport, MemoryError>> + Send;
    fn export_page(
        &self,
        namespaces: Option<&[String]>,
        cursor: Option<&ExportCursor>,
        limit: usize,
    ) -> impl Future<Output = Result<(Vec<MemoryRecord>, Option<ExportCursor>), MemoryError>> + Send;

    // Provided method
    fn export_all(
        &self,
        namespaces: Option<&[String]>,
    ) -> impl Future<Output = Result<Vec<MemoryRecord>, MemoryError>> + Send { ... }
}
Expand description

Ordinary operations shared by local and authenticated remote memory backends.

Implementations own their namespace and storage boundary. Returned records are ordered deterministically by the implementation, direct mutations use key versions as compare-and-swap preconditions, and each implementation captures its authoritative operation time internally. Dropping a returned future requests cancellation. Implementations may finish an already-started atomic storage transaction after cancellation.

Required Methods§

Source

fn scan( &self, query: &str, limit: usize, ) -> impl Future<Output = Result<MemoryScan, MemoryError>> + Send

Searches visible records and records scan telemetry.

Source

fn read( &self, ids: &[i64], keys: &[MemoryKey], ) -> impl Future<Output = Result<Vec<MemoryRecord>, MemoryError>> + Send

Reads unversioned IDs and versioned keys, recording use telemetry.

Source

fn list( &self, ) -> impl Future<Output = Result<Vec<MemoryRecord>, MemoryError>> + Send

Lists a deterministic window that excludes expired probationary records.

Implementations return at most MemoryLimits::records records so interactive inspection does not grow with the complete shared corpus. Full transfer uses paginated export instead.

Source

fn put( &self, content: &str, replacement: Option<MemoryKey>, ) -> impl Future<Output = Result<MemoryRecord, MemoryError>> + Send

Inserts content or compare-and-swap replaces replacement.

Source

fn delete( &self, key: MemoryKey, ) -> impl Future<Output = Result<(), MemoryError>> + Send

Compare-and-swap deletes key.

Deleting an already-absent key succeeds, making safe request replay idempotent. An existing record with a different version returns MemoryError::Conflict.

Source

fn sync( &self, memories: &[MemoryRecord], ) -> impl Future<Output = Result<SyncReport, MemoryError>> + Send

Atomically applies an authoritative full snapshot to the owned namespace.

Records absent from memories are deleted. Input is validated before commit, IDs remain stable, and future insertions must not reuse IDs observed in the snapshot.

Source

fn export_page( &self, namespaces: Option<&[String]>, cursor: Option<&ExportCursor>, limit: usize, ) -> impl Future<Output = Result<(Vec<MemoryRecord>, Option<ExportCursor>), MemoryError>> + Send

Exports one page in stable (namespace, id) order after cursor.

The page is a point-in-time transaction snapshot. limit is clamped to the protocol bound; callers continue only with the exact returned cursor. Cancellation before storage work starts prevents the operation; an already-started transaction may finish.

Provided Methods§

Source

fn export_all( &self, namespaces: Option<&[String]>, ) -> impl Future<Output = Result<Vec<MemoryRecord>, MemoryError>> + Send

Collects a complete bounded export through the paginated storage contract.

The collector rejects non-progressing cursors and stops before retaining more records or content than a local store can import.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl MemoryStore for LocalMemoryStore

Source§

impl MemoryStore for RemoteMemoryClient

Source§

impl MemoryStore for SelectedMemoryStore

Available on crate features client and local only.