pub struct StorageBackedSessionView { /* private fields */ }
Expand description
SessionView adapter backed by BoxedSessionStorage
This adapter implements the SessionView trait by delegating to the underlying session storage backend. It handles:
- Reading/writing session state
- Reading/writing session metadata (with
__meta__:
prefix) - Error conversion from storage errors to String
§Architecture
Middleware → SessionView → StorageBackedSessionView → BoxedSessionStorage
§Example
use std::sync::Arc;
use turul_mcp_session_storage::InMemorySessionStorage;
use turul_http_mcp_server::middleware::StorageBackedSessionView;
let storage = Arc::new(InMemorySessionStorage::new());
let session_id = "test-session-123".to_string();
// Create adapter
let session_view = StorageBackedSessionView::new(session_id, storage);
// Middleware can now use SessionView trait methods
// session_view.get_state("key").await
Implementations§
Trait Implementations§
Source§impl SessionView for StorageBackedSessionView
impl SessionView for StorageBackedSessionView
Source§fn session_id(&self) -> &str
fn session_id(&self) -> &str
Get the unique session identifier Read more
Source§fn get_state<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_state<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a state value from the session Read more
Source§fn set_state<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_state<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Set a state value in the session Read more
Auto Trait Implementations§
impl Freeze for StorageBackedSessionView
impl !RefUnwindSafe for StorageBackedSessionView
impl Send for StorageBackedSessionView
impl Sync for StorageBackedSessionView
impl Unpin for StorageBackedSessionView
impl !UnwindSafe for StorageBackedSessionView
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