pub trait SessionStore:
Send
+ Sync
+ 'static {
// Required methods
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 mut SessionRecord,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn save<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 SessionRecord,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<SessionRecord>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Storage backend for MCP session metadata.
Implementations persist SessionRecords keyed by session ID. The default
implementation is MemorySessionStore; external stores (Redis, Postgres,
etc.) typically live in separate crates.
§Semantics
createmust ensure the ID in the record is unique, retrying ID generation if necessary.savetrusts the caller’s ID and performs an upsert.loadreturnsNonefor unknown or expired sessions. Implementations may choose to return expired records and let the caller decide, or filter them out.deleteis idempotent – removing a non-existent ID is not an error.
Required Methods§
Sourcefn create<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 mut SessionRecord,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 mut SessionRecord,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Create a new session record.
The implementation must ensure record.id does not collide with an
existing session, regenerating the ID if needed.
Sourcefn save<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 SessionRecord,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 SessionRecord,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Persist an existing session record. The ID is trusted.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".