Group

Struct Group 

Source
pub struct Group<S, E>(/* private fields */);
Expand description

middleware builder type for grouping and nesting multiple middlewares.

§Examples

// a simple passthrough middleware function.
async fn mw<S, Req>(svc: &S, req: Req) -> Result<S::Response, S::Error>
where
    S: Service<Req>
{
    svc.call(req).await
}

fn_service(|_: ()| async { Ok::<_, Infallible>(()) })
    .enclosed(
        // group multiple middlewares and apply it to fn_service.
        Group::new()
            .enclosed_fn(mw)
            .enclosed_fn(mw)
    );

Implementations§

Source§

impl<S, E> Group<S, E>

Source

pub const fn new() -> Self

Trait Implementations§

Source§

impl<S, E> Clone for Group<S, E>

Source§

fn clone(&self) -> Self

Returns a duplicate 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<S, E> Service<Result<S, E>> for Group<S, E>

Source§

type Response = S

The Ok part of output future.
Source§

type Error = E

The Err part of output future.
Source§

async fn call(&self, res: Result<S, E>) -> Result<Self::Response, Self::Error>

Source§

impl<S, E> Copy for Group<S, E>

Auto Trait Implementations§

§

impl<S, E> Freeze for Group<S, E>

§

impl<S, E> RefUnwindSafe for Group<S, E>

§

impl<S, E> Send for Group<S, E>

§

impl<S, E> Sync for Group<S, E>

§

impl<S, E> Unpin for Group<S, E>

§

impl<S, E> UnwindSafe for Group<S, E>

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<S, Arg> ServiceExt<Arg> for S
where S: Service<Arg>,

Source§

fn enclosed<T>(self, build: T) -> EnclosedBuilder<Self, T>
where T: Service<Result<Self::Response, Self::Error>>, Self: Sized,

Enclose Self with given T as Service<<Self as Service<_>>::Response>>. In other word T would take Self’s Service::Response type as it’s generic argument of Service<_> impl.
Source§

fn enclosed_fn<T, Req, O>(self, func: T) -> EnclosedFnBuilder<Self, T>
where T: AsyncFn(&Self::Response, Req) -> O + Clone, Self: Sized,

Function version of Self::enclosed method.
Source§

fn map<F, Res, ResMap>(self, mapper: F) -> MapBuilder<Self, F>
where F: Fn(Res) -> ResMap + Clone, Self: Sized,

Mutate <<Self::Response as Service<Req>>::Future as Future>::Output type with given closure.
Source§

fn map_err<F, Err, ErrMap>(self, err: F) -> MapErrorBuilder<Self, F>
where F: Fn(Err) -> ErrMap + Clone, Self: Sized,

Mutate <Self::Response as Service<Req>>::Error type with given closure.
Source§

fn and_then<F>(self, factory: F) -> PipelineT<Self, F, BuildAndThen>
where F: Service<Arg>, Self: Sized,

Chain another service factory who’s service takes Self’s Service::Response output as Service::Request.
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.