Skip to main content

Provider

Trait Provider 

Source
pub trait Provider:
    Send
    + Sync
    + Debug {
    // Required methods
    fn name(&self) -> &'static str;
    fn remember(&self, cx: &Context, new: New) -> Result<Memory, Error>;
    fn list(
        &self,
        cx: &Context,
        scope: Option<Scope>,
        kind: Option<Kind>,
    ) -> Result<Found, Error>;
    fn get(&self, cx: &Context, id: &str) -> Result<Memory, Error>;
    fn update(
        &self,
        cx: &Context,
        id: &str,
        change: Change,
    ) -> Result<Memory, Error>;
    fn forget(&self, cx: &Context, id: &str) -> Result<Memory, Error>;
    fn put(&self, cx: &Context, m: &Memory) -> Result<Memory, Error>;

    // Provided method
    fn recall(
        &self,
        cx: &Context,
        query: &str,
        scope: Option<Scope>,
        limit: Option<usize>,
    ) -> Result<Found, Error> { ... }
}
Expand description

A memory store. Every method resolves the project and session scopes from cx; scope: None means every scope cx reaches. Providers keep no cache that could go stale against their store.

Required Methods§

Source

fn name(&self) -> &'static str

The settings name: files, sqlite, or kosmonaut.

Source

fn remember(&self, cx: &Context, new: New) -> Result<Memory, Error>

Source

fn list( &self, cx: &Context, scope: Option<Scope>, kind: Option<Kind>, ) -> Result<Found, Error>

Newest first.

Source

fn get(&self, cx: &Context, id: &str) -> Result<Memory, Error>

Source

fn update( &self, cx: &Context, id: &str, change: Change, ) -> Result<Memory, Error>

Source

fn forget(&self, cx: &Context, id: &str) -> Result<Memory, Error>

Remove a memory; returns what was removed.

Source

fn put(&self, cx: &Context, m: &Memory) -> Result<Memory, Error>

Keep m as it is, under its id and with its times, replacing a memory with the same id: how memories move between providers (transfer). m.path and m.score are ignored.

Provided Methods§

Source

fn recall( &self, cx: &Context, query: &str, scope: Option<Scope>, limit: Option<usize>, ) -> Result<Found, Error>

Memories matching query, best first; at most limit (DEFAULT_LIMIT when None, never more than MAX_LIMIT).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§