pub trait SessionStore: Send + Sync {
// Required methods
fn save(
&self,
asset: &SessionAsset,
) -> impl Future<Output = Result<(), StorageError>> + Send;
fn load(
&self,
id: &str,
) -> impl Future<Output = Result<SessionAsset, StorageError>> + Send;
fn list(
&self,
) -> impl Future<Output = Result<Vec<SessionMeta>, StorageError>> + Send;
fn delete(
&self,
id: &str,
) -> impl Future<Output = Result<(), StorageError>> + Send;
fn exists(
&self,
id: &str,
) -> impl Future<Output = Result<bool, StorageError>> + Send;
// Provided method
fn sync_status(&self) -> SyncStatus { ... }
}Expand description
Session storage abstraction.
Implementations must be thread-safe (Send + Sync) for use across async tasks.
§Design Principles
- Async: All operations are async for I/O efficiency
- Error Handling: Returns
StorageErrorfor consistent error handling - Metadata Efficiency:
list()returns lightweight metadata, not full assets
§Example
use orcs_runtime::session::{SessionStore, SessionAsset, StorageError};
async fn save_session(store: &impl SessionStore, asset: &SessionAsset) -> Result<(), StorageError> {
store.save(asset).await?;
println!("Saved session: {}", asset.id);
Ok(())
}Required Methods§
Sourcefn save(
&self,
asset: &SessionAsset,
) -> impl Future<Output = Result<(), StorageError>> + Send
fn save( &self, asset: &SessionAsset, ) -> impl Future<Output = Result<(), StorageError>> + Send
Saves a session asset.
If a session with the same ID exists, it will be overwritten.
Sourcefn load(
&self,
id: &str,
) -> impl Future<Output = Result<SessionAsset, StorageError>> + Send
fn load( &self, id: &str, ) -> impl Future<Output = Result<SessionAsset, StorageError>> + Send
Sourcefn list(
&self,
) -> impl Future<Output = Result<Vec<SessionMeta>, StorageError>> + Send
fn list( &self, ) -> impl Future<Output = Result<Vec<SessionMeta>, StorageError>> + Send
Lists all session metadata.
Returns lightweight metadata for each session, sorted by updated_at descending.
Provided Methods§
Sourcefn sync_status(&self) -> SyncStatus
fn sync_status(&self) -> SyncStatus
Returns the current sync status.
For local-only stores, this returns SyncStatus::offline().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.