Skip to main content

SessionStorage

Trait SessionStorage 

Source
pub trait SessionStorage: WasmCompatSend + WasmCompatSync {
    // Required methods
    fn save(
        &self,
        session: &Session,
    ) -> impl Future<Output = Result<(), StorageError>> + WasmCompatSend;
    fn load(
        &self,
        id: &str,
    ) -> impl Future<Output = Result<Session, StorageError>> + WasmCompatSend;
    fn list(
        &self,
    ) -> impl Future<Output = Result<Vec<SessionSummary>, StorageError>> + WasmCompatSend;
    fn delete(
        &self,
        id: &str,
    ) -> impl Future<Output = Result<(), StorageError>> + WasmCompatSend;
}
Expand description

Trait for persisting and loading sessions.

§Example

use neuron_runtime::*;

let storage = InMemorySessionStorage::new();
let session = Session::new("s-1", "/tmp".into());
storage.save(&session).await?;
let loaded = storage.load("s-1").await?;
assert_eq!(loaded.id, "s-1");

Required Methods§

Source

fn save( &self, session: &Session, ) -> impl Future<Output = Result<(), StorageError>> + WasmCompatSend

Save a session (create or update).

Source

fn load( &self, id: &str, ) -> impl Future<Output = Result<Session, StorageError>> + WasmCompatSend

Load a session by ID.

Source

fn list( &self, ) -> impl Future<Output = Result<Vec<SessionSummary>, StorageError>> + WasmCompatSend

List all session summaries.

Source

fn delete( &self, id: &str, ) -> impl Future<Output = Result<(), StorageError>> + WasmCompatSend

Delete a session by ID.

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.

Implementors§