Struct tower_async::util::ServiceFn

source ·
pub struct ServiceFn<T> { /* private fields */ }
Available on crate feature util only.
Expand description

A Service implemented by a closure.

See service_fn for more details.

Trait Implementations§

source§

impl<T: Clone> Clone for ServiceFn<T>

source§

fn clone(&self) -> ServiceFn<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> Debug for ServiceFn<T>

source§

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

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

impl<T, F, Request, R, E> Service<Request> for ServiceFn<T>where T: Fn(Request) -> F, F: Future<Output = Result<R, E>>,

§

type Response = R

Responses given by the service.
§

type Error = E

Errors produced by the service.
source§

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

Process the request and return the response asynchronously.
source§

impl<T: Copy> Copy for ServiceFn<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for ServiceFn<T>where T: RefUnwindSafe,

§

impl<T> Send for ServiceFn<T>where T: Send,

§

impl<T> Sync for ServiceFn<T>where T: Sync,

§

impl<T> Unpin for ServiceFn<T>where T: Unpin,

§

impl<T> UnwindSafe for ServiceFn<T>where T: 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.