pub struct ConversationStore { /* private fields */ }Expand description
File-backed conversation store.
The store is safe to share between async tasks in one process. It uses a process-local mutex around index and document updates; it is not intended for concurrent writers in multiple server processes.
Implementations§
Source§impl ConversationStore
impl ConversationStore
pub fn open(root: impl Into<PathBuf>) -> Result<Self, ConversationStoreError>
Sourcepub fn create(
&self,
owner: impl Into<String>,
agent: impl Into<String>,
) -> Result<Conversation, ConversationStoreError>
pub fn create( &self, owner: impl Into<String>, agent: impl Into<String>, ) -> Result<Conversation, ConversationStoreError>
Creates a conversation and makes it the active conversation for owner.
Sourcepub fn active(
&self,
owner: &str,
) -> Result<Option<Conversation>, ConversationStoreError>
pub fn active( &self, owner: &str, ) -> Result<Option<Conversation>, ConversationStoreError>
Returns the active conversation for owner, if one has been created.
Sourcepub fn list(
&self,
owner: &str,
) -> Result<Vec<Conversation>, ConversationStoreError>
pub fn list( &self, owner: &str, ) -> Result<Vec<Conversation>, ConversationStoreError>
Lists non-archived conversations belonging to owner, newest activity first.
Sourcepub fn list_archived(
&self,
owner: &str,
) -> Result<Vec<Conversation>, ConversationStoreError>
pub fn list_archived( &self, owner: &str, ) -> Result<Vec<Conversation>, ConversationStoreError>
Lists archived conversations belonging to owner, newest activity first.
Sourcepub fn set_active(
&self,
owner: &str,
id: ConversationId,
) -> Result<(), ConversationStoreError>
pub fn set_active( &self, owner: &str, id: ConversationId, ) -> Result<(), ConversationStoreError>
Selects an existing conversation as the active one for its owner.
Sourcepub fn get(
&self,
id: ConversationId,
) -> Result<Conversation, ConversationStoreError>
pub fn get( &self, id: ConversationId, ) -> Result<Conversation, ConversationStoreError>
Loads a conversation by its stable identifier.
Sourcepub fn rename(
&self,
owner: &str,
id: ConversationId,
title: impl Into<String>,
) -> Result<Conversation, ConversationStoreError>
pub fn rename( &self, owner: &str, id: ConversationId, title: impl Into<String>, ) -> Result<Conversation, ConversationStoreError>
Changes the display title of a conversation belonging to owner.
Sourcepub fn set_selected_family(
&self,
owner: &str,
id: ConversationId,
family_id: Option<FamilyId>,
) -> Result<Conversation, ConversationStoreError>
pub fn set_selected_family( &self, owner: &str, id: ConversationId, family_id: Option<FamilyId>, ) -> Result<Conversation, ConversationStoreError>
Persists the family selected for a conversation owned by the caller.
Sourcepub fn set_archived(
&self,
owner: &str,
id: ConversationId,
archived: bool,
) -> Result<Conversation, ConversationStoreError>
pub fn set_archived( &self, owner: &str, id: ConversationId, archived: bool, ) -> Result<Conversation, ConversationStoreError>
Archives or restores a conversation belonging to owner.
Archiving also clears the active pointer when it refers to this conversation. The conversation document and its message history remain untouched and can be restored later.
Sourcepub fn delete(
&self,
owner: &str,
id: ConversationId,
) -> Result<(), ConversationStoreError>
pub fn delete( &self, owner: &str, id: ConversationId, ) -> Result<(), ConversationStoreError>
Permanently deletes a conversation belonging to owner.
If the conversation is currently active for that owner, its active pointer is removed as part of the same process-local critical section.
Sourcepub fn save_messages(
&self,
id: ConversationId,
messages: Vec<Message>,
) -> Result<Conversation, ConversationStoreError>
pub fn save_messages( &self, id: ConversationId, messages: Vec<Message>, ) -> Result<Conversation, ConversationStoreError>
Replaces the complete model-visible history of a conversation.