Struct tower_async::util::Then

source ·
pub struct Then<S, F> { /* private fields */ }
Available on crate feature util only.
Expand description

Service returned by the then combinator.

Implementations§

source§

impl<S, F> Then<S, F>

source

pub fn new(inner: S, f: F) -> Self

Creates a new Then service.

source

pub fn layer(f: F) -> ThenLayer<F>

Returns a new Layer that produces Then services.

This is a convenience function that simply calls ThenLayer::new.

Trait Implementations§

source§

impl<S: Clone, F: Clone> Clone for Then<S, F>

source§

fn clone(&self) -> Then<S, F>

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<S, F> Debug for Then<S, F>where S: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<S, F, Request, Response, Error, Fut> Service<Request> for Then<S, F>where S: Service<Request>, S::Error: Into<Error>, F: Fn(Result<S::Response, S::Error>) -> Fut, Fut: Future<Output = Result<Response, Error>>,

§

type Response = Response

Responses given by the service.
§

type Error = Error

Errors produced by the service.
source§

async fn call(&self, request: Request) -> Result<Self::Response, Self::Error>

Process the request and return the response asynchronously.

Auto Trait Implementations§

§

impl<S, F> RefUnwindSafe for Then<S, F>where F: RefUnwindSafe, S: RefUnwindSafe,

§

impl<S, F> Send for Then<S, F>where F: Send, S: Send,

§

impl<S, F> Sync for Then<S, F>where F: Sync, S: Sync,

§

impl<S, F> Unpin for Then<S, F>where F: Unpin, S: Unpin,

§

impl<S, F> UnwindSafe for Then<S, F>where F: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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<M, S, Target, Request> MakeService<Target, Request> for Mwhere M: Service<Target, Response = S>, S: Service<Request>,

§

type Response = <S as Service<Request>>::Response

Available on crate feature make only.
Responses given by the service
§

type Error = <S as Service<Request>>::Error

Available on crate feature make only.
Errors produced by the service
§

type Service = S

Available on crate feature make only.
The Service value created by this factory
§

type MakeError = <M as Service<Target>>::Error

Available on crate feature make only.
Errors produced while building a service.
source§

async fn make_service( &self, target: Target ) -> Result<<M as MakeService<Target, Request>>::Service, <M as MakeService<Target, Request>>::MakeError>

Available on crate feature make only.
Create and return a new service value asynchronously.
source§

fn into_service(self) -> IntoService<Self, Request>where Self: Sized,

Available on crate feature make only.
Consume this MakeService and convert it into a Service. Read more
source§

fn as_service(&self) -> AsService<'_, Self, Request>where Self: Sized,

Available on crate feature make only.
Convert this MakeService into a Service without consuming the original MakeService. Read more
source§

impl<T, Request> ServiceExt<Request> for Twhere T: Service<Request> + ?Sized,

source§

fn oneshot( self, req: Request ) -> impl Future<Output = Result<Self::Response, Self::Error>>where Self: Sized,

Available on crate feature util only.
Consume this Service, calling it with the provided request once and only once.
source§

fn and_then<F>(self, f: F) -> AndThen<Self, F>where Self: Sized, F: Clone,

Available on crate feature util only.
Executes a new future after this service’s future resolves. Read more
source§

fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>where Self: Sized, F: Fn(Self::Response) -> Response,

Available on crate feature util only.
Maps this service’s response value to a different value. Read more
source§

fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>where Self: Sized, F: Fn(Self::Error) -> Error,

Available on crate feature util only.
Maps this service’s error value to a different value. Read more
source§

fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>where Self: Sized, Error: From<Self::Error>, F: Fn(Result<Self::Response, Self::Error>) -> Result<Response, Error>,

Available on crate feature util only.
Maps this service’s result type (Result<Self::Response, Self::Error>) to a different value, regardless of whether the future succeeds or fails. Read more
source§

fn map_request<F, NewRequest>(self, f: F) -> MapRequest<Self, F>where Self: Sized, F: Fn(NewRequest) -> Request,

Available on crate feature util only.
Composes a function in front of the service. Read more
source§

fn filter<F, NewRequest>(self, filter: F) -> Filter<Self, F>where Self: Sized, F: Predicate<NewRequest>,

Available on crate features util and filter only.
Composes this service with a Filter that conditionally accepts or rejects requests based on a predicate. Read more
source§

fn filter_async<F, NewRequest>(self, filter: F) -> AsyncFilter<Self, F>where Self: Sized, F: AsyncPredicate<NewRequest>,

Available on crate features util and filter only.
Composes this service with an AsyncFilter that conditionally accepts or rejects requests based on an [async predicate]. Read more
source§

fn then<F, Response, Error, Fut>(self, f: F) -> Then<Self, F>where Self: Sized, Error: From<Self::Error>, F: Fn(Result<Self::Response, Self::Error>) -> Fut, Fut: Future<Output = Result<Response, Error>>,

Available on crate feature util only.
Composes an asynchronous function after this service. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.