Skip to main content

MessageStore

Trait MessageStore 

Source
pub trait MessageStore: Send + Sync {
    // Required methods
    fn save_messages<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        conversation_id: &'life1 str,
        messages: &'life2 [ChatMessage],
        scope: &'life3 Scope,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MessageId>, MemoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn get_messages<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        conversation_id: &'life1 str,
        last_n: Option<usize>,
        scope: &'life2 Scope,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<ChatMessage>, MemoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn list_conversations<'life0, 'life1, 'async_trait>(
        &'life0 self,
        scope: &'life1 Scope,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, MemoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_messages<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        conversation_id: &'life1 str,
        scope: &'life2 Scope,
    ) -> Pin<Box<dyn Future<Output = Result<u64, MemoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

Persistence interface for chat messages.

Implementations MUST be Send + Sync so that Arc<dyn MessageStore> can be shared across async tasks.

Required Methods§

Source

fn save_messages<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, conversation_id: &'life1 str, messages: &'life2 [ChatMessage], scope: &'life3 Scope, ) -> Pin<Box<dyn Future<Output = Result<Vec<MessageId>, MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Save one or more messages to a conversation. Returns the ids of the saved messages.

Source

fn get_messages<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, conversation_id: &'life1 str, last_n: Option<usize>, scope: &'life2 Scope, ) -> Pin<Box<dyn Future<Output = Result<Vec<ChatMessage>, MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Retrieve messages from a conversation, optionally limited to the last N messages. Results are ordered by seq ascending.

Source

fn list_conversations<'life0, 'life1, 'async_trait>( &'life0 self, scope: &'life1 Scope, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all conversation ids visible to the given scope.

Source

fn delete_messages<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, conversation_id: &'life1 str, scope: &'life2 Scope, ) -> Pin<Box<dyn Future<Output = Result<u64, MemoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delete all messages in a conversation. Returns the number of rows deleted.

Implementors§