Struct MiddlewareChain

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

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

Implementations§

Source§

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

Source

pub fn new() -> MiddlewareChain<T>

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

Source

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

Assign a runnable function to this middleware chain

Source

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

Source

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

Run the middleware chain once

Source

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

Source

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§

Source§

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

Source§

fn clone(&self) -> MiddlewareChain<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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

Source§

fn default() -> MiddlewareChain<T>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for MiddlewareChain<T>

§

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.