pub struct InMemoryCheckpointer<S>{ /* private fields */ }Expand description
In-process checkpointer backed by a
HashMap<(tenant_id, thread_id), Vec<Checkpoint>>. The
composite key encodes Invariant 11 (multi-tenant isolation):
the same thread_id under two tenants resolves to two distinct
histories.
Cheap to clone — internal state is Arc<Mutex<...>>-shared.
Implementations§
Source§impl<S> InMemoryCheckpointer<S>
impl<S> InMemoryCheckpointer<S>
Sourcepub fn total_checkpoints(&self) -> usize
pub fn total_checkpoints(&self) -> usize
Total number of checkpoints stored across all
(tenant_id, thread_id) partitions. Test helper.
Sourcepub fn thread_count(&self) -> usize
pub fn thread_count(&self) -> usize
Number of distinct (tenant_id, thread_id) partitions that
have at least one checkpoint.
Trait Implementations§
Source§impl<S> Checkpointer<S> for InMemoryCheckpointer<S>
impl<S> Checkpointer<S> for InMemoryCheckpointer<S>
Source§fn put<'life0, 'async_trait>(
&'life0 self,
checkpoint: Checkpoint<S>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn put<'life0, 'async_trait>(
&'life0 self,
checkpoint: Checkpoint<S>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Persist a checkpoint. The checkpoint’s own
(tenant_id, thread_id) fields define its addressing.Source§fn get_latest<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 ThreadKey,
) -> Pin<Box<dyn Future<Output = Result<Option<Checkpoint<S>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_latest<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 ThreadKey,
) -> Pin<Box<dyn Future<Output = Result<Option<Checkpoint<S>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load the most recent checkpoint for
key. Verb-family
get per .claude/rules/naming.md — single-item primary-
key (most-recent) lookup, returns Option<Checkpoint<S>>.Source§fn get_by_id<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 ThreadKey,
id: &'life2 CheckpointId,
) -> Pin<Box<dyn Future<Output = Result<Option<Checkpoint<S>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_by_id<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 ThreadKey,
id: &'life2 CheckpointId,
) -> Pin<Box<dyn Future<Output = Result<Option<Checkpoint<S>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Look up a specific checkpoint by id within
key’s scope.
Verb-family get — primary-key lookup.Source§fn list_history<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 ThreadKey,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Checkpoint<S>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_history<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 ThreadKey,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<Checkpoint<S>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Return the thread’s checkpoint history, most recent first.
limit caps the result size (usize::MAX for “all”).Source§fn update_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 ThreadKey,
parent_id: &'life2 CheckpointId,
new_state: S,
) -> Pin<Box<dyn Future<Output = Result<CheckpointId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn update_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 ThreadKey,
parent_id: &'life2 CheckpointId,
new_state: S,
) -> Pin<Box<dyn Future<Output = Result<CheckpointId>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Time-travel write: create a fresh checkpoint that branches off
parent_id, replacing only the state. The new checkpoint
inherits next_node from its parent and records parent_id
so history renders branches correctly. Read moreSource§impl<S> Clone for InMemoryCheckpointer<S>
impl<S> Clone for InMemoryCheckpointer<S>
Source§fn clone(&self) -> InMemoryCheckpointer<S>
fn clone(&self) -> InMemoryCheckpointer<S>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<S> Freeze for InMemoryCheckpointer<S>
impl<S> !RefUnwindSafe for InMemoryCheckpointer<S>
impl<S> Send for InMemoryCheckpointer<S>
impl<S> Sync for InMemoryCheckpointer<S>
impl<S> Unpin for InMemoryCheckpointer<S>
impl<S> UnsafeUnpin for InMemoryCheckpointer<S>
impl<S> !UnwindSafe for InMemoryCheckpointer<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more