pub struct Contexts { /* private fields */ }Expand description
The in-memory registry of contexts + their durable mirror.
Implementations§
Source§impl Contexts
impl Contexts
pub fn new(model_window: u64) -> Contexts
Sourcepub fn restore(&mut self, envelopes: &[Envelope]) -> Vec<String>
pub fn restore(&mut self, envelopes: &[Envelope]) -> Vec<String>
Adopt restored context envelopes.
pub fn get(&self, id: &str) -> Option<&ContextState>
pub fn get_mut(&mut self, id: &str) -> Option<&mut ContextState>
Sourcepub fn root(&mut self) -> &mut ContextState
pub fn root(&mut self) -> &mut ContextState
Get or create the root context.
Sourcepub fn conversation(
&mut self,
id: &str,
principal: Option<&str>,
) -> &mut ContextState
pub fn conversation( &mut self, id: &str, principal: Option<&str>, ) -> &mut ContextState
Get or create a conversation context.
pub fn ids(&self) -> Vec<String>
pub fn len(&self) -> usize
Sourcepub fn max_est_tokens(&self) -> u64
pub fn max_est_tokens(&self) -> u64
The token estimate of the largest live context (for agent_context_tokens).
pub fn is_empty(&self) -> bool
pub fn remove(&mut self, id: &str) -> Option<ContextState>
Sourcepub fn checkpoint(
&mut self,
durable: &Durable,
) -> Result<Vec<String>, StoreError>
pub fn checkpoint( &mut self, durable: &Durable, ) -> Result<Vec<String>, StoreError>
Checkpoint every dirty context — called after each turn and after each compaction, which bounds a crash’s loss to the work in flight.
Returns the ids written. A clean context is skipped, so repeated calls are cheap and the write count tracks real change.
Auto Trait Implementations§
impl Freeze for Contexts
impl RefUnwindSafe for Contexts
impl Send for Contexts
impl Sync for Contexts
impl Unpin for Contexts
impl UnsafeUnpin for Contexts
impl UnwindSafe for Contexts
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