Struct gotham::middleware::state::StateMiddleware
source · [−]pub struct StateMiddleware<T> where
T: Clone + RefUnwindSafe + StateData + Sync, { /* private fields */ }
Expand description
Middleware binding for generic types to enable easy shared state.
This acts as nothing more than a Middleware
instance which will
attach a generic type to a request State
, however it removes a
barrier for users to Gotham who might not know the internals.
The generic types inside this struct can (and will) be cloned often, so wrap your expensive types in reference counts as needed.
Implementations
sourceimpl<T> StateMiddleware<T> where
T: Clone + RefUnwindSafe + StateData + Sync,
impl<T> StateMiddleware<T> where
T: Clone + RefUnwindSafe + StateData + Sync,
Main implementation.
Trait Implementations
sourceimpl<T: Clone> Clone for StateMiddleware<T> where
T: Clone + RefUnwindSafe + StateData + Sync,
impl<T: Clone> Clone for StateMiddleware<T> where
T: Clone + RefUnwindSafe + StateData + Sync,
sourcefn clone(&self) -> StateMiddleware<T>
fn clone(&self) -> StateMiddleware<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T> Middleware for StateMiddleware<T> where
T: Clone + RefUnwindSafe + StateData + Sync,
impl<T> Middleware for StateMiddleware<T> where
T: Clone + RefUnwindSafe + StateData + Sync,
Middleware
trait implementation.
sourcefn call<Chain>(self, state: State, chain: Chain) -> Box<HandlerFuture> where
Chain: FnOnce(State) -> Box<HandlerFuture>,
fn call<Chain>(self, state: State, chain: Chain) -> Box<HandlerFuture> where
Chain: FnOnce(State) -> Box<HandlerFuture>,
Attaches the inner generic value to the request state.
This will enable the Handler
to borrow the value directly from the state.
sourceimpl<T> NewMiddleware for StateMiddleware<T> where
T: Clone + RefUnwindSafe + StateData + Sync,
impl<T> NewMiddleware for StateMiddleware<T> where
T: Clone + RefUnwindSafe + StateData + Sync,
NewMiddleware
trait implementation.
sourcefn new_middleware(&self) -> Result<Self::Instance>
fn new_middleware(&self) -> Result<Self::Instance>
Clones the current middleware to a new instance.
type Instance = Self
type Instance = Self
The type of Middleware
created by the NewMiddleware
.
Auto Trait Implementations
impl<T> RefUnwindSafe for StateMiddleware<T>
impl<T> Send for StateMiddleware<T>
impl<T> Sync for StateMiddleware<T>
impl<T> Unpin for StateMiddleware<T> where
T: Unpin,
impl<T> UnwindSafe for StateMiddleware<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more