ChatHistoryRepository

Trait ChatHistoryRepository 

Source
pub trait ChatHistoryRepository: Send + Sync {
    // Required methods
    fn create_conversation<'life0, 'async_trait>(
        &'life0 self,
        conv: NewConversation,
    ) -> Pin<Box<dyn Future<Output = Result<i64, ChatHistoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn list_conversations<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Conversation>, ChatHistoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_conversation<'life0, 'async_trait>(
        &'life0 self,
        id: i64,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Conversation>, ChatHistoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn update_conversation<'life0, 'async_trait>(
        &'life0 self,
        id: i64,
        update: ConversationUpdate,
    ) -> Pin<Box<dyn Future<Output = Result<(), ChatHistoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete_conversation<'life0, 'async_trait>(
        &'life0 self,
        id: i64,
    ) -> Pin<Box<dyn Future<Output = Result<(), ChatHistoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_conversation_count<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<i64, ChatHistoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_messages<'life0, 'async_trait>(
        &'life0 self,
        conversation_id: i64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, ChatHistoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn save_message<'life0, 'async_trait>(
        &'life0 self,
        msg: NewMessage,
    ) -> Pin<Box<dyn Future<Output = Result<i64, ChatHistoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn update_message<'life0, 'async_trait>(
        &'life0 self,
        id: i64,
        content: String,
        metadata: Option<Value>,
    ) -> Pin<Box<dyn Future<Output = Result<(), ChatHistoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete_message_and_subsequent<'life0, 'async_trait>(
        &'life0 self,
        id: i64,
    ) -> Pin<Box<dyn Future<Output = Result<i64, ChatHistoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_message_count<'life0, 'async_trait>(
        &'life0 self,
        conversation_id: i64,
    ) -> Pin<Box<dyn Future<Output = Result<i64, ChatHistoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Port for chat history persistence operations.

This trait defines the interface for storing and retrieving chat conversations and messages. Implementations handle the actual storage mechanism (SQLite, etc.).

Required Methods§

Source

fn create_conversation<'life0, 'async_trait>( &'life0 self, conv: NewConversation, ) -> Pin<Box<dyn Future<Output = Result<i64, ChatHistoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create a new conversation.

Source

fn list_conversations<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Conversation>, ChatHistoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List all conversations, ordered by most recently updated.

Source

fn get_conversation<'life0, 'async_trait>( &'life0 self, id: i64, ) -> Pin<Box<dyn Future<Output = Result<Option<Conversation>, ChatHistoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a specific conversation by ID.

Source

fn update_conversation<'life0, 'async_trait>( &'life0 self, id: i64, update: ConversationUpdate, ) -> Pin<Box<dyn Future<Output = Result<(), ChatHistoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Update conversation metadata.

Source

fn delete_conversation<'life0, 'async_trait>( &'life0 self, id: i64, ) -> Pin<Box<dyn Future<Output = Result<(), ChatHistoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete a conversation and all its messages.

Source

fn get_conversation_count<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<i64, ChatHistoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get conversation count.

Source

fn get_messages<'life0, 'async_trait>( &'life0 self, conversation_id: i64, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, ChatHistoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get all messages for a conversation, ordered chronologically.

Source

fn save_message<'life0, 'async_trait>( &'life0 self, msg: NewMessage, ) -> Pin<Box<dyn Future<Output = Result<i64, ChatHistoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Save a new message and update conversation timestamp.

Source

fn update_message<'life0, 'async_trait>( &'life0 self, id: i64, content: String, metadata: Option<Value>, ) -> Pin<Box<dyn Future<Output = Result<(), ChatHistoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Update a message’s content and optionally its metadata.

Source

fn delete_message_and_subsequent<'life0, 'async_trait>( &'life0 self, id: i64, ) -> Pin<Box<dyn Future<Output = Result<i64, ChatHistoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete a message and all subsequent messages in the same conversation. Returns the number of messages deleted.

Source

fn get_message_count<'life0, 'async_trait>( &'life0 self, conversation_id: i64, ) -> Pin<Box<dyn Future<Output = Result<i64, ChatHistoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get message count for a conversation.

Implementors§