Skip to main content

InMemoryConversationStore

Struct InMemoryConversationStore 

Source
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

Source

pub fn new() -> Self

Source

pub fn thread_info(&self, thread_id: &ThreadId<str>) -> Option<ThreadInfo>

Snapshot one thread’s bookkeeping, if the thread exists.

Source

pub fn set_thread_info(&self, thread_id: &ThreadId<str>, info: ThreadInfo)

Restore (or overwrite) one thread’s bookkeeping.

Source

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.

Source

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).

Source

pub fn thread_compaction_summaries( &self, thread_id: &ThreadId<str>, ) -> Vec<CompactionSummary>

Snapshot one thread’s compaction summaries.

Source

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).

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ConversationStore for InMemoryConversationStore

Source§

type Error = InMemoryStoreError

Source§

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,

Return whether an exact root or child thread record exists without creating it.
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,

Load history for a session. Both bounds are counted in messages from the start of the thread: 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 more
Source§

fn 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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Whether 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.
Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Source§

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,

Load the latest compaction summary. When 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,

Load full history for a thread including ancestor context and compaction. Walks backwards through ancestors to find the most recent compaction summary, skipping all earlier ancestors (their content is in the summary). Returns (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).
Source§

impl Default for InMemoryConversationStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more