Skip to main content

MemoryBackend

Trait MemoryBackend 

Source
pub trait MemoryBackend: Component {
    // Required methods
    fn append(&self, cx: &mut Cx, msg: Value) -> Result<()>;
    fn recent(&self, cx: &mut Cx, count: u32) -> Result<Vec<Value>>;
    fn search(&self, cx: &mut Cx, query: Expr, k: u32) -> Result<Vec<Value>>;
    fn snapshot(&self, cx: &mut Cx) -> Result<Expr>;
    fn restore(&self, cx: &mut Cx, snap: Expr) -> Result<()>;
}
Expand description

Behavior shared by every memory backend: append, query, and snapshot/restore.

Required Methods§

Source

fn append(&self, cx: &mut Cx, msg: Value) -> Result<()>

Appends one message to the backend.

Source

fn recent(&self, cx: &mut Cx, count: u32) -> Result<Vec<Value>>

Returns up to count most recent entries.

Source

fn search(&self, cx: &mut Cx, query: Expr, k: u32) -> Result<Vec<Value>>

Returns up to k entries matching query.

Source

fn snapshot(&self, cx: &mut Cx) -> Result<Expr>

Captures the full backend state as an expression.

Source

fn restore(&self, cx: &mut Cx, snap: Expr) -> Result<()>

Replaces the backend state from a prior snapshot.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§