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").awaitImplementations§
Source§impl StorageBackedSessionView
impl StorageBackedSessionView
Sourcepub fn new(
session_id: String,
storage: Arc<dyn SessionStorage<Error = SessionStorageError>>,
) -> StorageBackedSessionView
pub fn new( session_id: String, storage: Arc<dyn SessionStorage<Error = SessionStorageError>>, ) -> StorageBackedSessionView
Create a new session view adapter
§Parameters
session_id: The session ID to operate onstorage: The storage backend to delegate to
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
'life0: 'async_trait,
'life1: 'async_trait,
StorageBackedSessionView: '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
'life0: 'async_trait,
'life1: 'async_trait,
StorageBackedSessionView: '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
'life0: 'async_trait,
'life1: 'async_trait,
StorageBackedSessionView: '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
'life0: 'async_trait,
'life1: 'async_trait,
StorageBackedSessionView: 'async_trait,
Set a state value in the session Read more
Source§fn get_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, String>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
StorageBackedSessionView: 'async_trait,
fn get_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, String>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
StorageBackedSessionView: 'async_trait,
Get a metadata value from the session Read more
Source§fn set_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
StorageBackedSessionView: 'async_trait,
fn set_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
StorageBackedSessionView: 'async_trait,
Set a metadata 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.