[]Struct thruster::MiddlewareChain

pub struct MiddlewareChain<T> where
    T: 'static, 
{ pub chain: Chain<T>, pub assigned: bool, }

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

chain: Chain<T>assigned: bool

Methods

impl<T> MiddlewareChain<T> where
    T: 'static, 

pub fn new() -> MiddlewareChain<T>

Creates a new, blank (i.e. will panic if run,) MiddlewareChain

pub fn assign(&mut self, chain: Chain<T>)

Assign a runnable function to this middleware chain

pub fn assign_legacy(&mut self, chain: Chain<T>)

pub fn run(
    &self,
    context: T
) -> Pin<Box<dyn Future<Output = T> + 'static + Send>>

Run the middleware chain once

pub fn chain(&mut self, chain: MiddlewareChain<T>)

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

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, 

impl<T> Default for MiddlewareChain<T> where
    T: 'static, 

Auto Trait Implementations

impl<T> !RefUnwindSafe for MiddlewareChain<T>

impl<T> Send for MiddlewareChain<T>

impl<T> Sync for MiddlewareChain<T>

impl<T> Unpin for MiddlewareChain<T>

impl<T> !UnwindSafe for MiddlewareChain<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.