[][src]Trait actix_service::NewService

pub trait NewService<Request> {
    type Response;
    type Error;
    type Service: Service<Request, Response = Self::Response, Error = Self::Error>;
    type InitError;
    type Future: Future<Item = Self::Service, Error = Self::InitError>;
    fn new_service(&self) -> Self::Future;

    fn apply<T, I, F, Out, Req>(
        self,
        service: I,
        f: F
    ) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>>
    where
        Self: Sized,
        T: NewService<Req, InitError = Self::InitError, Error = Self::Error>,
        I: IntoNewService<T, Req>,
        F: Fn(Self::Response, &mut T::Service) -> Out + Clone,
        Out: IntoFuture<Error = Self::Error>
, { ... }
fn and_then<F, B>(self, new_service: F) -> AndThenNewService<Self, B>
    where
        Self: Sized,
        F: IntoNewService<B, Self::Response>,
        B: NewService<Self::Response, Error = Self::Error, InitError = Self::InitError>
, { ... }
fn from_err<E>(self) -> FromErrNewService<Self, E>
    where
        Self: Sized,
        E: From<Self::Error>
, { ... }
fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B>
    where
        Self: Sized,
        F: IntoNewService<B, Result<Self::Response, Self::Error>>,
        B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>
, { ... }
fn map<F, R>(self, f: F) -> MapNewService<Self, F, R>
    where
        Self: Sized,
        F: Fn(Self::Response) -> R
, { ... }
fn map_err<F, E>(self, f: F) -> MapErrNewService<Self, F, E>
    where
        Self: Sized,
        F: Fn(Self::Error) -> E
, { ... }
fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E>
    where
        Self: Sized,
        F: Fn(Self::InitError) -> E
, { ... } }

Creates new Service values.

Acts as a service factory. This is useful for cases where new Service values must be produced. One case is a TCP servier listener. The listner accepts new TCP streams, obtains a new Service value using the NewService trait, and uses that new Service value to process inbound requests on that new TCP stream.

Request - request handled by the service

Associated Types

type Response

Responses given by the service

type Error

Errors produced by the service

type Service: Service<Request, Response = Self::Response, Error = Self::Error>

The Service value created by this factory

type InitError

Errors produced while building a service.

type Future: Future<Item = Self::Service, Error = Self::InitError>

The future of the Service instance.

Loading content...

Required methods

fn new_service(&self) -> Self::Future

Create and return a new service value asynchronously.

Loading content...

Provided methods

fn apply<T, I, F, Out, Req>(
    self,
    service: I,
    f: F
) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where
    Self: Sized,
    T: NewService<Req, InitError = Self::InitError, Error = Self::Error>,
    I: IntoNewService<T, Req>,
    F: Fn(Self::Response, &mut T::Service) -> Out + Clone,
    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, new_service: F) -> AndThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Self::Response>,
    B: NewService<Self::Response, Error = Self::Error, InitError = Self::InitError>, 

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

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

NewService that create service to map this service's error and new service's init error to any error implementing From for this servicesError`.

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

fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Result<Self::Response, Self::Error>>,
    B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, 

Create NewService to 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 future and returns a wrapped version of it.

fn map<F, R>(self, f: F) -> MapNewService<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.

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

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

fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E> where
    Self: Sized,
    F: Fn(Self::InitError) -> E, 

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

Loading content...

Implementors

impl<A, B, Request> NewService<Request> for AndThenNewService<A, B> where
    A: NewService<Request>,
    B: NewService<A::Response, Error = A::Error, InitError = A::InitError>, 
[src]

type Response = B::Response

type Error = A::Error

type Service = AndThen<A::Service, B::Service>

type InitError = A::InitError

type Future = AndThenNewServiceFuture<A, B, Request>

fn apply<T, I, F, Out, Req>(
    self,
    service: I,
    f: F
) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where
    Self: Sized,
    T: NewService<Req, InitError = Self::InitError, Error = Self::Error>,
    I: IntoNewService<T, Req>,
    F: Fn(Self::Response, &mut T::Service) -> Out + Clone,
    Out: IntoFuture<Error = Self::Error>, 
[src]

fn and_then<F, B>(self, new_service: F) -> AndThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Self::Response>,
    B: NewService<Self::Response, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Result<Self::Response, Self::Error>>,
    B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

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

fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E> where
    Self: Sized,
    F: Fn(Self::InitError) -> E, 
[src]

impl<A, B, Request> NewService<Request> for ThenNewService<A, B> where
    A: NewService<Request>,
    B: NewService<Result<A::Response, A::Error>, Error = A::Error, InitError = A::InitError>, 
[src]

type Response = B::Response

type Error = A::Error

type Service = Then<A::Service, B::Service>

type InitError = A::InitError

type Future = ThenNewServiceFuture<A, B, Request>

fn apply<T, I, F, Out, Req>(
    self,
    service: I,
    f: F
) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where
    Self: Sized,
    T: NewService<Req, InitError = Self::InitError, Error = Self::Error>,
    I: IntoNewService<T, Req>,
    F: Fn(Self::Response, &mut T::Service) -> Out + Clone,
    Out: IntoFuture<Error = Self::Error>, 
[src]

fn and_then<F, B>(self, new_service: F) -> AndThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Self::Response>,
    B: NewService<Self::Response, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Result<Self::Response, Self::Error>>,
    B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

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

fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E> where
    Self: Sized,
    F: Fn(Self::InitError) -> E, 
[src]

impl<A, E, Request> NewService<Request> for FromErrNewService<A, E> where
    A: NewService<Request>,
    E: From<A::Error>, 
[src]

type Response = A::Response

type Error = E

type Service = FromErr<A::Service, E>

type InitError = A::InitError

type Future = FromErrNewServiceFuture<A, E, Request>

fn apply<T, I, F, Out, Req>(
    self,
    service: I,
    f: F
) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where
    Self: Sized,
    T: NewService<Req, InitError = Self::InitError, Error = Self::Error>,
    I: IntoNewService<T, Req>,
    F: Fn(Self::Response, &mut T::Service) -> Out + Clone,
    Out: IntoFuture<Error = Self::Error>, 
[src]

fn and_then<F, B>(self, new_service: F) -> AndThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Self::Response>,
    B: NewService<Self::Response, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Result<Self::Response, Self::Error>>,
    B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

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

fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E> where
    Self: Sized,
    F: Fn(Self::InitError) -> E, 
[src]

impl<A, F, E, Request> NewService<Request> for MapErrNewService<A, F, E> where
    A: NewService<Request>,
    F: Fn(A::Error) -> E + Clone
[src]

type Response = A::Response

type Error = E

type Service = MapErr<A::Service, F, E>

type InitError = A::InitError

type Future = MapErrNewServiceFuture<A, F, E, Request>

fn apply<T, I, F, Out, Req>(
    self,
    service: I,
    f: F
) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where
    Self: Sized,
    T: NewService<Req, InitError = Self::InitError, Error = Self::Error>,
    I: IntoNewService<T, Req>,
    F: Fn(Self::Response, &mut T::Service) -> Out + Clone,
    Out: IntoFuture<Error = Self::Error>, 
[src]

fn and_then<F, B>(self, new_service: F) -> AndThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Self::Response>,
    B: NewService<Self::Response, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Result<Self::Response, Self::Error>>,
    B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

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

fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E> where
    Self: Sized,
    F: Fn(Self::InitError) -> E, 
[src]

impl<A, F, E, Request> NewService<Request> for MapInitErr<A, F, E> where
    A: NewService<Request>,
    F: Fn(A::InitError) -> E + Clone
[src]

type Response = A::Response

type Error = A::Error

type Service = A::Service

type InitError = E

type Future = MapInitErrFuture<A, F, E, Request>

fn apply<T, I, F, Out, Req>(
    self,
    service: I,
    f: F
) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where
    Self: Sized,
    T: NewService<Req, InitError = Self::InitError, Error = Self::Error>,
    I: IntoNewService<T, Req>,
    F: Fn(Self::Response, &mut T::Service) -> Out + Clone,
    Out: IntoFuture<Error = Self::Error>, 
[src]

fn and_then<F, B>(self, new_service: F) -> AndThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Self::Response>,
    B: NewService<Self::Response, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Result<Self::Response, Self::Error>>,
    B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

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

fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E> where
    Self: Sized,
    F: Fn(Self::InitError) -> E, 
[src]

impl<A, F, Request, Response> NewService<Request> for MapNewService<A, F, Response> where
    A: NewService<Request>,
    F: Fn(A::Response) -> Response + Clone
[src]

type Response = Response

type Error = A::Error

type Service = Map<A::Service, F, Response>

type InitError = A::InitError

type Future = MapNewServiceFuture<A, F, Request, Response>

fn apply<T, I, F, Out, Req>(
    self,
    service: I,
    f: F
) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where
    Self: Sized,
    T: NewService<Req, InitError = Self::InitError, Error = Self::Error>,
    I: IntoNewService<T, Req>,
    F: Fn(Self::Response, &mut T::Service) -> Out + Clone,
    Out: IntoFuture<Error = Self::Error>, 
[src]

fn and_then<F, B>(self, new_service: F) -> AndThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Self::Response>,
    B: NewService<Self::Response, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Result<Self::Response, Self::Error>>,
    B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

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

fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E> where
    Self: Sized,
    F: Fn(Self::InitError) -> E, 
[src]

impl<F, R, E, S, Request> NewService<Request> for F where
    F: Fn() -> R,
    R: IntoFuture<Item = S, Error = E>,
    S: Service<Request>, 
[src]

type Response = S::Response

type Error = S::Error

type Service = S

type InitError = E

type Future = R::Future

fn apply<T, I, F, Out, Req>(
    self,
    service: I,
    f: F
) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where
    Self: Sized,
    T: NewService<Req, InitError = Self::InitError, Error = Self::Error>,
    I: IntoNewService<T, Req>,
    F: Fn(Self::Response, &mut T::Service) -> Out + Clone,
    Out: IntoFuture<Error = Self::Error>, 
[src]

fn and_then<F, B>(self, new_service: F) -> AndThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Self::Response>,
    B: NewService<Self::Response, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Result<Self::Response, Self::Error>>,
    B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

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

fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E> where
    Self: Sized,
    F: Fn(Self::InitError) -> E, 
[src]

impl<F, Req, Resp, Err, Fut> NewService<Req> for FnNewService<F, Req, Resp, Err, Fut> where
    F: FnMut(Req) -> Fut + Clone,
    Fut: IntoFuture<Item = Resp, Error = Err>, 
[src]

type Response = Resp

type Error = Err

type Service = FnService<F, Req, Resp, Err, Fut>

type InitError = ()

type Future = FutureResult<Self::Service, Self::InitError>

fn apply<T, I, F, Out, Req>(
    self,
    service: I,
    f: F
) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where
    Self: Sized,
    T: NewService<Req, InitError = Self::InitError, Error = Self::Error>,
    I: IntoNewService<T, Req>,
    F: Fn(Self::Response, &mut T::Service) -> Out + Clone,
    Out: IntoFuture<Error = Self::Error>, 
[src]

fn and_then<F, B>(self, new_service: F) -> AndThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Self::Response>,
    B: NewService<Self::Response, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Result<Self::Response, Self::Error>>,
    B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

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

fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E> where
    Self: Sized,
    F: Fn(Self::InitError) -> E, 
[src]

impl<T, F, In, Out, Request> NewService<In> for ApplyNewService<T, F, In, Out, Request> where
    T: NewService<Request>,
    F: Fn(In, &mut T::Service) -> Out + Clone,
    Out: IntoFuture,
    Out::Error: From<T::Error>, 
[src]

type Response = Out::Item

type Error = Out::Error

type Service = Apply<T::Service, F, In, Out, Request>

type InitError = T::InitError

type Future = ApplyNewServiceFuture<T, F, In, Out, Request>

fn apply<T, I, F, Out, Req>(
    self,
    service: I,
    f: F
) -> AndThenNewService<Self, ApplyNewService<T, F, Self::Response, Out, Req>> where
    Self: Sized,
    T: NewService<Req, InitError = Self::InitError, Error = Self::Error>,
    I: IntoNewService<T, Req>,
    F: Fn(Self::Response, &mut T::Service) -> Out + Clone,
    Out: IntoFuture<Error = Self::Error>, 
[src]

fn and_then<F, B>(self, new_service: F) -> AndThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Self::Response>,
    B: NewService<Self::Response, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B> where
    Self: Sized,
    F: IntoNewService<B, Result<Self::Response, Self::Error>>,
    B: NewService<Result<Self::Response, Self::Error>, Error = Self::Error, InitError = Self::InitError>, 
[src]

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

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

fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E> where
    Self: Sized,
    F: Fn(Self::InitError) -> E, 
[src]

Loading content...