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§
Sourcefn 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 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,
Sourcefn 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 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,
Sourcefn 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 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,
Sourcefn 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,
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§
Sourcefn 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 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,
Sourcefn 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_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.
Sourcefn 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 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.
Sourcefn 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,
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,
impl<T> MessageStore for Arc<T>where
T: MessageStore + ?Sized,
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,
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,
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,
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,
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,
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,
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,
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§
impl MessageStore for InMemoryStore
impl MessageStore for SqliteStore
sqlite only.