Skip to main content

DynMemory

Trait DynMemory 

Source
pub trait DynMemory: Send + Sync {
    // Required methods
    fn remember<'a>(
        &'a self,
        scope: &'a MemoryScope,
        payload: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = Result<MemoryId, LaserError>> + Send + 'a>>;
    fn recall<'a>(
        &'a self,
        scope: &'a MemoryScope,
        query: &'a MemoryQuery,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryItem>, LaserError>> + Send + 'a>>;
    fn improve<'a>(
        &'a self,
        scope: &'a MemoryScope,
        feedback: Feedback,
    ) -> Pin<Box<dyn Future<Output = Result<MemoryId, LaserError>> + Send + 'a>>;
    fn forget<'a>(
        &'a self,
        scope: &'a MemoryScope,
        id: MemoryId,
    ) -> Pin<Box<dyn Future<Output = Result<(), LaserError>> + Send + 'a>>;

    // Provided method
    fn append<'a>(
        &'a self,
        scope: &'a MemoryScope,
        id: MemoryId,
        kind: MemoryKind,
        payload: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = Result<MemoryId, LaserError>> + Send + 'a>> { ... }
}
Expand description

The dyn-safe form of Memory, returning boxed futures so an external backend composes into the facade as a trait object. Memory is RPITIT (via trait_variant), so it is not object-safe. A blanket impl adapts any Memory, and a custom backend plugs in through Laser::memory_custom. This mirrors the boxed-future seam pattern the reliable consumer uses for AgentMiddleware.

Required Methods§

Source

fn remember<'a>( &'a self, scope: &'a MemoryScope, payload: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<MemoryId, LaserError>> + Send + 'a>>

Source

fn recall<'a>( &'a self, scope: &'a MemoryScope, query: &'a MemoryQuery, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryItem>, LaserError>> + Send + 'a>>

Source

fn improve<'a>( &'a self, scope: &'a MemoryScope, feedback: Feedback, ) -> Pin<Box<dyn Future<Output = Result<MemoryId, LaserError>> + Send + 'a>>

Source

fn forget<'a>( &'a self, scope: &'a MemoryScope, id: MemoryId, ) -> Pin<Box<dyn Future<Output = Result<(), LaserError>> + Send + 'a>>

Provided Methods§

Source

fn append<'a>( &'a self, scope: &'a MemoryScope, id: MemoryId, kind: MemoryKind, payload: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<MemoryId, LaserError>> + Send + 'a>>

Boxed typed append, with the custom backend’s remember fallback.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<M: Memory + Send + Sync> DynMemory for M