pub struct FileManagedStateStore { /* private fields */ }Expand description
Records each session as one JSON file under a directory.
The first store here that reports Durability::CrashDurable: a write is fsynced
through a temporary file and a rename, so another process can reconstruct a session
after loss. InMemoryManagedStateStore cannot, and says so.
One file per session rather than one file for all of them, so two sessions being checkpointed at once do not contend, and a corrupt write can only lose the session it belonged to.
§Example
use adk_managed::state_store::{Durability, FileManagedStateStore, ManagedStateStore};
let store = FileManagedStateStore::new("/var/lib/adk/sessions");
assert_eq!(store.durability(), Durability::CrashDurable);Implementations§
Trait Implementations§
Source§impl Debug for FileManagedStateStore
impl Debug for FileManagedStateStore
Source§impl ManagedStateStore for FileManagedStateStore
impl ManagedStateStore for FileManagedStateStore
Source§fn durability(&self) -> Durability
fn durability(&self) -> Durability
What this store guarantees after process loss.
Source§fn save<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
state: ManagedSessionState,
) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
state: ManagedSessionState,
) -> Pin<Box<dyn Future<Output = Result<(), RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Records the state of
session_id, replacing any previous snapshot. Read moreSource§fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ManagedSessionState>, RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ManagedSessionState>, RuntimeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl Freeze for FileManagedStateStore
impl RefUnwindSafe for FileManagedStateStore
impl Send for FileManagedStateStore
impl Sync for FileManagedStateStore
impl Unpin for FileManagedStateStore
impl UnsafeUnpin for FileManagedStateStore
impl UnwindSafe for FileManagedStateStore
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