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§
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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_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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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 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.
Sourcefn 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,
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.