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§
Sourcefn remember<'a>(
&'a self,
scope: &'a MemoryScope,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<MemoryId, LaserError>> + Send + 'a>>
fn remember<'a>( &'a self, scope: &'a MemoryScope, payload: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<MemoryId, LaserError>> + Send + 'a>>
Boxed Memory::remember.
Sourcefn recall<'a>(
&'a self,
scope: &'a MemoryScope,
query: &'a MemoryQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryItem>, 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>>
Boxed Memory::recall.
Sourcefn improve<'a>(
&'a self,
scope: &'a MemoryScope,
feedback: Feedback,
) -> Pin<Box<dyn Future<Output = Result<MemoryId, LaserError>> + Send + 'a>>
fn improve<'a>( &'a self, scope: &'a MemoryScope, feedback: Feedback, ) -> Pin<Box<dyn Future<Output = Result<MemoryId, LaserError>> + Send + 'a>>
Boxed Memory::improve.
Sourcefn forget<'a>(
&'a self,
scope: &'a MemoryScope,
id: MemoryId,
) -> Pin<Box<dyn Future<Output = Result<(), LaserError>> + Send + 'a>>
fn forget<'a>( &'a self, scope: &'a MemoryScope, id: MemoryId, ) -> Pin<Box<dyn Future<Output = Result<(), LaserError>> + Send + 'a>>
Boxed Memory::forget.
Provided Methods§
Sourcefn append<'a>(
&'a self,
scope: &'a MemoryScope,
id: MemoryId,
kind: MemoryKind,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<MemoryId, LaserError>> + Send + 'a>>
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".