pub struct SessionInjection { /* private fields */ }
Expand description
Write-only mechanism for middleware to populate session state
Prevents middleware from interfering with core session management while allowing controlled injection of custom state and metadata.
§Design
- Write-only: Middleware cannot read existing session state
- Deferred application: Changes applied after all middleware succeed
- Isolation: Each middleware’s changes are independent
§Examples
use turul_http_mcp_server::middleware::SessionInjection;
use serde_json::json;
let mut injection = SessionInjection::new();
// Set typed state
injection.set_state("user_id", json!(12345));
injection.set_state("role", json!("admin"));
// Set metadata
injection.set_metadata("authenticated_at", json!("2025-10-04T12:00:00Z"));
// State and metadata are applied to session after middleware succeeds
assert!(!injection.is_empty());
Implementations§
Trait Implementations§
Source§impl Clone for SessionInjection
impl Clone for SessionInjection
Source§fn clone(&self) -> SessionInjection
fn clone(&self) -> SessionInjection
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SessionInjection
impl Debug for SessionInjection
Source§impl Default for SessionInjection
impl Default for SessionInjection
Source§fn default() -> SessionInjection
fn default() -> SessionInjection
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SessionInjection
impl RefUnwindSafe for SessionInjection
impl Send for SessionInjection
impl Sync for SessionInjection
impl Unpin for SessionInjection
impl UnwindSafe for SessionInjection
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