Skip to main content

MessageStore

Trait MessageStore 

Source
pub trait MessageStore: Send + Sync {
    // Required methods
    fn append<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 ThreadId,
        message: Message,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn get_history<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 ThreadId,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn clear<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 ThreadId,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn replace_history<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 ThreadId,
        messages: Vec<Message>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn count<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 ThreadId,
    ) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
    fn append_compaction<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _thread_id: &'life1 ThreadId,
        _messages: Vec<Message>,
        _source_message_count: usize,
        _retained_message_count: usize,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
    fn append_repair<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 ThreadId,
        _repair_message: Message,
        balanced_messages: Vec<Message>,
        _source_message_count: usize,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
    fn get_transcript<'life0, 'life1, 'async_trait>(
        &'life0 self,
        thread_id: &'life1 ThreadId,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

Trait for storing and retrieving conversation messages. Implement this trait to persist messages to your storage backend.

Required Methods§

Source

fn append<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, message: Message, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Append a message to the thread’s history

§Errors

Returns an error if the message cannot be stored.

Source

fn get_history<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Get all messages for a thread

§Errors

Returns an error if the history cannot be retrieved.

Source

fn clear<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Clear all messages for a thread

§Errors

Returns an error if the messages cannot be cleared.

Source

fn replace_history<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, messages: Vec<Message>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Replace the entire message history for a thread. Used for context compaction to replace old messages with a summary.

§Errors

Returns an error if the history cannot be replaced.

Provided Methods§

Source

fn count<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, ) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Get the message count for a thread

§Errors

Returns an error if the count cannot be retrieved.

Source

fn append_compaction<'life0, 'life1, 'async_trait>( &'life0 self, _thread_id: &'life1 ThreadId, _messages: Vec<Message>, _source_message_count: usize, _retained_message_count: usize, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Append a compaction boundary without deleting committed messages.

Backends that do not support append-only compaction reject the operation rather than falling back to destructive replacement.

§Errors

Returns an error when append-only compaction is unsupported or invalid.

Source

fn append_repair<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, _repair_message: Message, balanced_messages: Vec<Message>, _source_message_count: usize, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Repair orphaned tool-use history with a balanced effective projection.

The compatibility default replaces history. Append-only stores can override this method to retain the synthetic repair evidence separately.

§Errors

Returns an error if the balanced history cannot be installed.

Source

fn get_transcript<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Return the unabridged committed transcript.

Stores without compaction metadata return the same view as Self::get_history.

§Errors

Returns an error if the transcript cannot be retrieved.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T> MessageStore for Arc<T>
where T: MessageStore + ?Sized,

Source§

fn append<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, message: Message, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Source§

fn get_history<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Source§

fn clear<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Source§

fn count<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, ) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Source§

fn replace_history<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, messages: Vec<Message>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Source§

fn append_compaction<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, messages: Vec<Message>, source_message_count: usize, retained_message_count: usize, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Source§

fn append_repair<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, repair_message: Message, balanced_messages: Vec<Message>, source_message_count: usize, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Source§

fn get_transcript<'life0, 'life1, 'async_trait>( &'life0 self, thread_id: &'life1 ThreadId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Implementors§

Source§

impl MessageStore for InMemoryStore

Source§

impl MessageStore for SqliteStore

Available on crate feature sqlite only.