Trait ContextSmuggler
pub trait ContextSmuggler<S> {
// Required methods
fn inject_ctx(&mut self, ctx: Context<S>);
fn try_extract_ctx(&mut self) -> Option<Context<S>>;
}
Expand description
Trait to be implemented for any request that can “smuggle” Context
s.
- if the
http
feature is enabled it will already be implemented forrama_http_types::Request
; - for types that do have this capability and you work with tower services
which do not care about the specific type of the request that passes through it,
you can make use of
RequestStatePair
using the tower map-request capabilities, to easily swap between the pair and direct request format.
Required Methods§
fn inject_ctx(&mut self, ctx: Context<S>)
fn inject_ctx(&mut self, ctx: Context<S>)
inject the context into the smuggler.
fn try_extract_ctx(&mut self) -> Option<Context<S>>
fn try_extract_ctx(&mut self) -> Option<Context<S>>
try to extract the smuggled context out of the smuggle, which is only possible once.