pub struct InMemoryConversationStore { /* private fields */ }Expand description
An in-memory ConversationStore: threads, message history, the thread
tree, and compaction summaries, all in process memory.
Implementations§
Source§impl InMemoryConversationStore
impl InMemoryConversationStore
pub fn new() -> Self
Sourcepub fn thread_info(&self, thread_id: &ThreadId<str>) -> Option<ThreadInfo>
pub fn thread_info(&self, thread_id: &ThreadId<str>) -> Option<ThreadInfo>
Snapshot one thread’s bookkeeping, if the thread exists.
Sourcepub fn set_thread_info(&self, thread_id: &ThreadId<str>, info: ThreadInfo)
pub fn set_thread_info(&self, thread_id: &ThreadId<str>, info: ThreadInfo)
Restore (or overwrite) one thread’s bookkeeping.
Sourcepub fn thread_messages(
&self,
thread_id: &ThreadId<str>,
) -> Option<Vec<(InfinityMessage, String)>>
pub fn thread_messages( &self, thread_id: &ThreadId<str>, ) -> Option<Vec<(InfinityMessage, String)>>
Snapshot one thread’s messages (with their dedup IDs), if any were ever appended.
Sourcepub fn set_thread_messages(
&self,
thread_id: &ThreadId<str>,
messages: Vec<(InfinityMessage, String)>,
) -> bool
pub fn set_thread_messages( &self, thread_id: &ThreadId<str>, messages: Vec<(InfinityMessage, String)>, ) -> bool
Restore one thread’s messages. Returns true if messages for the
thread were already present (and have been overwritten).
Sourcepub fn thread_compaction_summaries(
&self,
thread_id: &ThreadId<str>,
) -> Vec<CompactionSummary>
pub fn thread_compaction_summaries( &self, thread_id: &ThreadId<str>, ) -> Vec<CompactionSummary>
Snapshot one thread’s compaction summaries.
Sourcepub fn set_thread_compaction_summaries(
&self,
thread_id: &ThreadId<str>,
summaries: Vec<CompactionSummary>,
) -> bool
pub fn set_thread_compaction_summaries( &self, thread_id: &ThreadId<str>, summaries: Vec<CompactionSummary>, ) -> bool
Restore one thread’s compaction summaries. Returns true if
summaries for the thread were already present (and overwritten).
Sourcepub fn spawn_thread_with_id(
&self,
new_thread_id: &ThreadId<str>,
parent_thread_id: &ThreadId<str>,
spawn_tool_call_id: &ToolCallId<str>,
is_for_subscription_event: bool,
context: SpawnContext,
)
pub fn spawn_thread_with_id( &self, new_thread_id: &ThreadId<str>, parent_thread_id: &ThreadId<str>, spawn_tool_call_id: &ToolCallId<str>, is_for_subscription_event: bool, context: SpawnContext, )
Spawn a child thread under parent_thread_id with a caller-chosen ID
(the trait-level spawn_thread
generates a UUID and delegates here). The spawn order — how much of
the parent’s history the child inherits — is derived from context:
the given cutoff for SpawnContext::InheritUpTo, and zero for
SpawnContext::Fresh (which additionally marks the thread as a
fresh-context boundary).
Trait Implementations§
Source§impl Clone for InMemoryConversationStore
impl Clone for InMemoryConversationStore
Source§impl ConversationStore for InMemoryConversationStore
impl ConversationStore for InMemoryConversationStore
type Error = InMemoryStoreError
fn ensure_root_thread<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn thread_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn thread_exists<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn load_history_up_to<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 ThreadId<str>,
start_from: Option<i64>,
up_to: Option<i64>,
) -> Pin<Box<dyn Future<Output = Result<Vec<InfinityMessage>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_history_up_to<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 ThreadId<str>,
start_from: Option<i64>,
up_to: Option<i64>,
) -> Pin<Box<dyn Future<Output = Result<Vec<InfinityMessage>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
start_from skips that many leading
messages, up_to truncates to that many leading messages (so
start_from: Some(a), up_to: Some(b) yields the a-th through b-1-th
messages, zero-based). None means unbounded. Read morefn append_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 ThreadId<str>,
messages: Vec<(InfinityMessage, String)>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn spawn_thread<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
parent_thread_id: &'life1 ThreadId<str>,
spawn_tool_call_id: &'life2 ToolCallId<str>,
is_for_subscription_event: bool,
context: SpawnContext,
) -> Pin<Box<dyn Future<Output = Result<ThreadId, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn is_thread_closed<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn close_thread<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn is_subscription_event_thread<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn is_fresh_context_thread<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn is_fresh_context_thread<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
thread_id was spawned with SpawnContext::Fresh (no
inherited history). Fresh threads act as a boundary in
load_history_with_ancestors:
neither they nor their descendants see any context from before the
fresh spawn.fn get_thread_parent_info<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
) -> Pin<Box<dyn Future<Output = Result<Option<(ThreadId, ToolCallId)>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_ancestor_chain<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<(ThreadId, i64)>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn mark_thread_as_compaction<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn is_compaction_thread<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_thread_spawn_order<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
) -> Pin<Box<dyn Future<Output = Result<Option<i64>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save_compaction_summary<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
summary: &'life2 str,
up_to_order: i64,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn load_latest_compaction_summary_up_to<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
up_to_order: Option<i64>,
) -> Pin<Box<dyn Future<Output = Result<Option<(String, i64)>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_latest_compaction_summary_up_to<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
up_to_order: Option<i64>,
) -> Pin<Box<dyn Future<Output = Result<Option<(String, i64)>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
up_to_order is Some(n),
only return summaries whose up_to_order is <= n.Source§fn load_history_with_ancestors<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
) -> Pin<Box<dyn Future<Output = Result<(Vec<InfinityMessage>, Option<i64>, usize), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_history_with_ancestors<'life0, 'life1, 'async_trait>(
&'life0 self,
thread_id: &'life1 ThreadId<str>,
) -> Pin<Box<dyn Future<Output = Result<(Vec<InfinityMessage>, Option<i64>, usize), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
(history, leaf_compacted_up_to, ancestor_prefix_len) where the
second element is the absolute store index the leaf thread’s compaction
covers (if any), and the third is how many messages at the front of the
history come from ancestors (not this thread’s own store).