[][src]Trait actix_service::ServiceExt

pub trait ServiceExt<Request>: Service<Request> {
    fn apply<T, I, F, Out, Req>(
        self,
        service: I,
        f: F
    ) -> AndThen<Self, Apply<T, F, Self::Response, Out, Req>>
    where
        Self: Sized,
        T: Service<Req, Error = Self::Error>,
        I: IntoService<T, Req>,
        F: Fn(Self::Response, &mut T) -> Out,
        Out: IntoFuture<Error = Self::Error>
, { ... }
fn and_then<F, B>(self, service: F) -> AndThen<Self, B>
    where
        Self: Sized,
        F: IntoService<B, Self::Response>,
        B: Service<Self::Response, Error = Self::Error>
, { ... }
fn from_err<E>(self) -> FromErr<Self, E>
    where
        Self: Sized,
        E: From<Self::Error>
, { ... }
fn then<B>(self, service: B) -> Then<Self, B>
    where
        Self: Sized,
        B: Service<Result<Self::Response, Self::Error>, Error = Self::Error>
, { ... }
fn map<F, R>(self, f: F) -> Map<Self, F, R>
    where
        Self: Sized,
        F: Fn(Self::Response) -> R
, { ... }
fn map_err<F, E>(self, f: F) -> MapErr<Self, F, E>
    where
        Self: Sized,
        F: Fn(Self::Error) -> E
, { ... } }

An extension trait for Services that provides a variety of convenient adapters

Provided methods

fn apply<T, I, F, Out, Req>(
    self,
    service: I,
    f: F
) -> AndThen<Self, Apply<T, F, Self::Response, Out, Req>> where
    Self: Sized,
    T: Service<Req, Error = Self::Error>,
    I: IntoService<T, Req>,
    F: Fn(Self::Response, &mut T) -> Out,
    Out: IntoFuture<Error = Self::Error>, 

Apply function to specified service and use it as a next service in chain.

fn and_then<F, B>(self, service: F) -> AndThen<Self, B> where
    Self: Sized,
    F: IntoService<B, Self::Response>,
    B: Service<Self::Response, Error = Self::Error>, 

Call another service after call to this one has resolved successfully.

This function can be used to chain two services together and ensure that the second service isn't called until call to the fist service have finished. Result of the call to the first service is used as an input parameter for the second service's call.

Note that this function consumes the receiving service and returns a wrapped version of it.

fn from_err<E>(self) -> FromErr<Self, E> where
    Self: Sized,
    E: From<Self::Error>, 

Map this service's error to any error implementing From for this servicesError`.

Note that this function consumes the receiving service and returns a wrapped version of it.

fn then<B>(self, service: B) -> Then<Self, B> where
    Self: Sized,
    B: Service<Result<Self::Response, Self::Error>, Error = Self::Error>, 

Chain on a computation for when a call to the service finished, passing the result of the call to the next service B.

Note that this function consumes the receiving service and returns a wrapped version of it.

fn map<F, R>(self, f: F) -> Map<Self, F, R> where
    Self: Sized,
    F: Fn(Self::Response) -> R, 

Map this service's output to a different type, returning a new service of the resulting type.

This function is similar to the Option::map or Iterator::map where it will change the type of the underlying service.

Note that this function consumes the receiving service and returns a wrapped version of it, similar to the existing map methods in the standard library.

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

Map this service's error to a different error, returning a new service.

This function is similar to the Result::map_err where it will change the error type of the underlying service. This is useful for example to ensure that services have the same error type.

Note that this function consumes the receiving service and returns a wrapped version of it.

Loading content...

Implementors

impl<T: ?Sized, Request> ServiceExt<Request> for T where
    T: Service<Request>, 
[src]

fn apply<T, I, F, Out, Req>(
    self,
    service: I,
    f: F
) -> AndThen<Self, Apply<T, F, Self::Response, Out, Req>> where
    Self: Sized,
    T: Service<Req, Error = Self::Error>,
    I: IntoService<T, Req>,
    F: Fn(Self::Response, &mut T) -> Out,
    Out: IntoFuture<Error = Self::Error>, 
[src]

fn and_then<F, B>(self, service: F) -> AndThen<Self, B> where
    Self: Sized,
    F: IntoService<B, Self::Response>,
    B: Service<Self::Response, Error = Self::Error>, 
[src]

fn from_err<E>(self) -> FromErr<Self, E> where
    Self: Sized,
    E: From<Self::Error>, 
[src]

fn then<B>(self, service: B) -> Then<Self, B> where
    Self: Sized,
    B: Service<Result<Self::Response, Self::Error>, Error = Self::Error>, 
[src]

fn map<F, R>(self, f: F) -> Map<Self, F, R> where
    Self: Sized,
    F: Fn(Self::Response) -> R, 
[src]

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

Loading content...