pub struct BlockingSessionStore<S: SessionStore + 'static> { /* private fields */ }Expand description
Adapter that wraps a synchronous SessionStore
and exposes async methods by running each call via tokio::task::spawn_blocking.
Custom messages are preserved faithfully: save/append snapshot custom
messages to their JSON envelope before crossing the thread boundary, and
load uses the registry configured at construction time to restore them.
To restore custom messages on load, provide the registry once at construction
via BlockingSessionStore::with_registry. A &CustomMessageRegistry
reference cannot cross spawn_blocking boundaries, so a per-call registry
is not supported.
Concurrent writes to the same session may corrupt the file. Callers are expected to enforce single-writer access.
Implementations§
Source§impl<S: SessionStore + 'static> BlockingSessionStore<S>
impl<S: SessionStore + 'static> BlockingSessionStore<S>
Sourcepub fn with_registry(self, registry: Arc<CustomMessageRegistry>) -> Self
pub fn with_registry(self, registry: Arc<CustomMessageRegistry>) -> Self
Attach a CustomMessageRegistry for deserializing custom messages on load.
Because &CustomMessageRegistry cannot cross spawn_blocking boundaries,
the registry must be provided once at construction rather than per call.
Source§impl<S: SessionStore + 'static> BlockingSessionStore<S>
impl<S: SessionStore + 'static> BlockingSessionStore<S>
Sourcepub fn save(
&self,
id: &str,
meta: &SessionMeta,
messages: &[AgentMessage],
) -> SessionStoreFuture<'_, ()>
pub fn save( &self, id: &str, meta: &SessionMeta, messages: &[AgentMessage], ) -> SessionStoreFuture<'_, ()>
Persist a session asynchronously, including both LLM and custom messages.
Sourcepub fn save_full(
&self,
id: &str,
meta: &SessionMeta,
messages: &[AgentMessage],
state: &Value,
) -> SessionStoreFuture<'_, SessionMeta>
pub fn save_full( &self, id: &str, meta: &SessionMeta, messages: &[AgentMessage], state: &Value, ) -> SessionStoreFuture<'_, SessionMeta>
Persist a session transcript plus its state snapshot asynchronously.
Sourcepub fn append(
&self,
id: &str,
messages: &[AgentMessage],
) -> SessionStoreFuture<'_, ()>
pub fn append( &self, id: &str, messages: &[AgentMessage], ) -> SessionStoreFuture<'_, ()>
Append messages to an existing session asynchronously.
Sourcepub fn load(
&self,
id: &str,
) -> SessionStoreFuture<'_, (SessionMeta, Vec<AgentMessage>)>
pub fn load( &self, id: &str, ) -> SessionStoreFuture<'_, (SessionMeta, Vec<AgentMessage>)>
Load a session by ID asynchronously.
Custom messages are restored using the registry supplied to
BlockingSessionStore::with_registry. Without a registry, custom
messages are discarded on load because the blocking adapter has no
serialized-wrapper fallback.
Sourcepub fn load_full(
&self,
id: &str,
) -> SessionStoreFuture<'_, (SessionMeta, Vec<AgentMessage>, Option<Value>)>
pub fn load_full( &self, id: &str, ) -> SessionStoreFuture<'_, (SessionMeta, Vec<AgentMessage>, Option<Value>)>
Load a session transcript plus its state snapshot asynchronously from one backend-defined read boundary.
Sourcepub fn list(&self) -> SessionStoreFuture<'_, Vec<SessionMeta>>
pub fn list(&self) -> SessionStoreFuture<'_, Vec<SessionMeta>>
List all saved sessions asynchronously.
Sourcepub fn delete(&self, id: &str) -> SessionStoreFuture<'_, ()>
pub fn delete(&self, id: &str) -> SessionStoreFuture<'_, ()>
Delete a session by ID asynchronously.
Sourcepub fn save_state(&self, id: &str, state: &Value) -> SessionStoreFuture<'_, ()>
pub fn save_state(&self, id: &str, state: &Value) -> SessionStoreFuture<'_, ()>
Save session state snapshot asynchronously.
Sourcepub fn load_state(&self, id: &str) -> SessionStoreFuture<'_, Option<Value>>
pub fn load_state(&self, id: &str) -> SessionStoreFuture<'_, Option<Value>>
Load session state snapshot asynchronously. Returns None if not set.
Sourcepub fn save_interrupt(
&self,
id: &str,
state: &InterruptState,
) -> SessionStoreFuture<'_, ()>
pub fn save_interrupt( &self, id: &str, state: &InterruptState, ) -> SessionStoreFuture<'_, ()>
Persist interrupt state for a session asynchronously.
Sourcepub fn load_interrupt(
&self,
id: &str,
) -> SessionStoreFuture<'_, Option<InterruptState>>
pub fn load_interrupt( &self, id: &str, ) -> SessionStoreFuture<'_, Option<InterruptState>>
Load interrupt state for a session asynchronously.
Sourcepub fn clear_interrupt(&self, id: &str) -> SessionStoreFuture<'_, ()>
pub fn clear_interrupt(&self, id: &str) -> SessionStoreFuture<'_, ()>
Clear interrupt state for a session asynchronously.
Sourcepub fn load_with_options(
&self,
id: &str,
options: &LoadOptions,
) -> SessionStoreFuture<'_, (SessionMeta, Vec<SessionEntry>)>
pub fn load_with_options( &self, id: &str, options: &LoadOptions, ) -> SessionStoreFuture<'_, (SessionMeta, Vec<SessionEntry>)>
Load a session with filtering options asynchronously.
Sourcepub fn search(
&self,
query: &str,
options: &SessionSearchOptions,
) -> SessionStoreFuture<'_, Vec<SessionHit>>
pub fn search( &self, query: &str, options: &SessionSearchOptions, ) -> SessionStoreFuture<'_, Vec<SessionHit>>
Search persisted sessions asynchronously.
Auto Trait Implementations§
impl<S> !RefUnwindSafe for BlockingSessionStore<S>
impl<S> !UnwindSafe for BlockingSessionStore<S>
impl<S> Freeze for BlockingSessionStore<S>
impl<S> Send for BlockingSessionStore<S>
impl<S> Sync for BlockingSessionStore<S>
impl<S> Unpin for BlockingSessionStore<S>
impl<S> UnsafeUnpin for BlockingSessionStore<S>where
Arc<S>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more