[−][src]Struct thruster::MiddlewareChain
The MiddlewareChain is used to wrap a series of middleware functions in such a way that the tail can be accessed and modified later on. This allows Thruster to properly compose pieces of middleware into a single long chain rather than relying on disperate parts.
Fields
runnable: Arc<Box<dyn Fn(T, &Option<Box<MiddlewareChain<T>>>) + 'static + Sync + Send>>
Methods
impl<T> MiddlewareChain<T> where
T: 'static,
[src]
T: 'static,
pub fn new() -> MiddlewareChain<T>
[src]
Creates a new, blank (i.e. will panic if run,) MiddlewareChain
pub fn assign(
&mut self,
chain: Box<dyn Fn(T, &Option<Box<MiddlewareChain<T>>>) + 'static + Sync + Send>
)
[src]
&mut self,
chain: Box<dyn Fn(T, &Option<Box<MiddlewareChain<T>>>) + 'static + Sync + Send>
)
Assign a runnable function to this middleware chain
pub fn run(
&self,
context: T
) -> Box<dyn Future<Item = T, Error = Error> + 'static + Send>
[src]
&self,
context: T
) -> Box<dyn Future<Item = T, Error = Error> + 'static + Send>
Run the middleware chain once
pub fn chain(&mut self, chain: MiddlewareChain<T>)
[src]
Concatenate two middleware chains. This will make this chains tail point
to the next chain. That means that calling next
in the final piece of
this chain will invoke the next chain rather than an "End of chain" panic
pub fn is_assigned(&self) -> bool
[src]
Tells if the chain has been assigned OR whether it is unassigned but has an assigned tail. If is only chained but has no assigned runnable, then this chain acts as a passthrough to the next one.
Trait Implementations
impl<T> Clone for MiddlewareChain<T> where
T: 'static,
[src]
T: 'static,
fn clone(&self) -> MiddlewareChain<T>
[src]
default fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> Default for MiddlewareChain<T> where
T: 'static,
[src]
T: 'static,
fn default() -> MiddlewareChain<T>
[src]
Auto Trait Implementations
impl<T> Send for MiddlewareChain<T>
impl<T> Sync for MiddlewareChain<T>
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.