2018-12-09 18:56:23 +01:00
|
|
|
use futures::{Future, IntoFuture, Poll};
|
2019-01-25 04:19:44 +01:00
|
|
|
|
2018-08-25 18:02:14 +02:00
|
|
|
mod and_then;
|
2019-01-25 04:19:44 +01:00
|
|
|
mod and_then_apply;
|
2019-02-03 19:42:27 +01:00
|
|
|
mod and_then_apply_fn;
|
2018-08-30 18:17:17 +02:00
|
|
|
mod apply;
|
2019-02-03 19:42:27 +01:00
|
|
|
mod blank;
|
2018-12-09 18:56:23 +01:00
|
|
|
mod cell;
|
2018-08-25 18:02:14 +02:00
|
|
|
mod fn_service;
|
2019-02-03 19:42:27 +01:00
|
|
|
mod fn_transform;
|
2018-09-04 21:07:13 +02:00
|
|
|
mod from_err;
|
2018-08-28 19:39:27 +02:00
|
|
|
mod map;
|
2018-08-25 18:02:14 +02:00
|
|
|
mod map_err;
|
|
|
|
mod map_init_err;
|
2018-10-03 06:47:50 +02:00
|
|
|
mod then;
|
2019-02-03 19:42:27 +01:00
|
|
|
mod transform;
|
2018-08-25 18:02:14 +02:00
|
|
|
|
|
|
|
pub use self::and_then::{AndThen, AndThenNewService};
|
2019-02-03 19:42:27 +01:00
|
|
|
use self::and_then_apply::{AndThenTransform, AndThenTransformNewService};
|
|
|
|
use self::and_then_apply_fn::{AndThenApply, AndThenApplyNewService};
|
2018-08-31 02:54:59 +02:00
|
|
|
pub use self::apply::{Apply, ApplyNewService};
|
2019-02-03 19:42:27 +01:00
|
|
|
pub use self::blank::{Blank, BlankNewService};
|
2018-08-29 21:20:35 +02:00
|
|
|
pub use self::fn_service::{FnNewService, FnService};
|
2019-02-03 19:42:27 +01:00
|
|
|
pub use self::fn_transform::{FnNewTransform, FnTransform};
|
2018-09-18 03:10:23 +02:00
|
|
|
pub use self::from_err::{FromErr, FromErrNewService};
|
2018-08-28 19:39:27 +02:00
|
|
|
pub use self::map::{Map, MapNewService};
|
2018-08-25 18:02:14 +02:00
|
|
|
pub use self::map_err::{MapErr, MapErrNewService};
|
|
|
|
pub use self::map_init_err::MapInitErr;
|
2018-10-03 06:47:50 +02:00
|
|
|
pub use self::then::{Then, ThenNewService};
|
2019-02-03 19:42:27 +01:00
|
|
|
pub use self::transform::{IntoNewTransform, IntoTransform, NewTransform, Transform};
|
2018-08-25 18:02:14 +02:00
|
|
|
|
2018-12-09 18:56:23 +01:00
|
|
|
/// An asynchronous function from `Request` to a `Response`.
|
2019-02-02 04:53:13 +01:00
|
|
|
pub trait Service {
|
|
|
|
/// Requests handled by the service.
|
|
|
|
type Request;
|
|
|
|
|
2018-12-09 18:56:23 +01:00
|
|
|
/// Responses given by the service.
|
|
|
|
type Response;
|
|
|
|
|
|
|
|
/// Errors produced by the service.
|
|
|
|
type Error;
|
|
|
|
|
|
|
|
/// The future response value.
|
|
|
|
type Future: Future<Item = Self::Response, Error = Self::Error>;
|
|
|
|
|
|
|
|
/// Returns `Ready` when the service is able to process requests.
|
|
|
|
///
|
|
|
|
/// If the service is at capacity, then `NotReady` is returned and the task
|
|
|
|
/// is notified when the service becomes ready again. This function is
|
|
|
|
/// expected to be called while on a task.
|
|
|
|
///
|
|
|
|
/// This is a **best effort** implementation. False positives are permitted.
|
|
|
|
/// It is permitted for the service to return `Ready` from a `poll_ready`
|
|
|
|
/// call and the next invocation of `call` results in an error.
|
|
|
|
fn poll_ready(&mut self) -> Poll<(), Self::Error>;
|
|
|
|
|
|
|
|
/// Process the request and return the response asynchronously.
|
|
|
|
///
|
|
|
|
/// This function is expected to be callable off task. As such,
|
|
|
|
/// implementations should take care to not call `poll_ready`. If the
|
|
|
|
/// service is at capacity and the request is unable to be handled, the
|
|
|
|
/// returned `Future` should resolve to an error.
|
|
|
|
///
|
|
|
|
/// Calling `call` without calling `poll_ready` is permitted. The
|
|
|
|
/// implementation must be resilient to this fact.
|
2019-02-02 04:53:13 +01:00
|
|
|
fn call(&mut self, req: Self::Request) -> Self::Future;
|
2018-12-13 03:32:19 +01:00
|
|
|
}
|
2018-12-09 18:56:23 +01:00
|
|
|
|
2018-12-13 03:32:19 +01:00
|
|
|
/// An extension trait for `Service`s that provides a variety of convenient
|
|
|
|
/// adapters
|
2019-02-02 04:53:13 +01:00
|
|
|
pub trait ServiceExt: Service {
|
2019-02-03 19:42:27 +01:00
|
|
|
/// Apply tranformation to specified service and use it as a next service in
|
|
|
|
/// chain.
|
|
|
|
fn apply<T, T1, B, B1>(self, transform: T1, service: B1) -> AndThenTransform<T, Self, B>
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
T: Transform<B, Request = Self::Response>,
|
|
|
|
T::Error: From<Self::Error>,
|
|
|
|
T1: IntoTransform<T, B>,
|
|
|
|
B: Service<Error = Self::Error>,
|
|
|
|
B1: IntoService<B>,
|
|
|
|
{
|
|
|
|
AndThenTransform::new(transform.into_transform(), self, service.into_service())
|
|
|
|
}
|
|
|
|
|
2018-09-18 01:16:42 +02:00
|
|
|
/// Apply function to specified service and use it as a next service in
|
|
|
|
/// chain.
|
2019-02-03 19:42:27 +01:00
|
|
|
fn apply_fn<F, B, B1, Out>(self, service: B1, f: F) -> AndThenApply<Self, B, F, Out>
|
2018-08-31 02:46:11 +02:00
|
|
|
where
|
|
|
|
Self: Sized,
|
2019-01-25 04:19:44 +01:00
|
|
|
F: FnMut(Self::Response, &mut B) -> Out,
|
|
|
|
Out: IntoFuture,
|
2019-01-25 05:41:42 +01:00
|
|
|
Out::Error: Into<Self::Error>,
|
2019-02-03 19:42:27 +01:00
|
|
|
B: Service<Error = Self::Error>,
|
|
|
|
B1: IntoService<B>,
|
2018-08-31 02:46:11 +02:00
|
|
|
{
|
2019-01-25 04:19:44 +01:00
|
|
|
AndThenApply::new(self, service, f)
|
2018-08-31 02:46:11 +02:00
|
|
|
}
|
|
|
|
|
2018-09-12 22:34:53 +02:00
|
|
|
/// 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.
|
2018-08-31 02:46:11 +02:00
|
|
|
fn and_then<F, B>(self, service: F) -> AndThen<Self, B>
|
2018-08-29 21:20:35 +02:00
|
|
|
where
|
|
|
|
Self: Sized,
|
2019-02-02 04:53:13 +01:00
|
|
|
F: IntoService<B>,
|
|
|
|
B: Service<Request = Self::Response, Error = Self::Error>,
|
2018-08-29 21:20:35 +02:00
|
|
|
{
|
2018-09-04 18:49:21 +02:00
|
|
|
AndThen::new(self, service.into_service())
|
2018-08-29 21:20:35 +02:00
|
|
|
}
|
|
|
|
|
2018-12-09 18:56:23 +01:00
|
|
|
/// Map this service's error to any error implementing `From` for
|
|
|
|
/// this service`s `Error`.
|
|
|
|
///
|
|
|
|
/// Note that this function consumes the receiving service and returns a
|
|
|
|
/// wrapped version of it.
|
2018-09-04 21:07:13 +02:00
|
|
|
fn from_err<E>(self) -> FromErr<Self, E>
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
E: From<Self::Error>,
|
|
|
|
{
|
|
|
|
FromErr::new(self)
|
|
|
|
}
|
|
|
|
|
2018-12-09 18:56:23 +01:00
|
|
|
/// 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.
|
2018-10-03 06:47:50 +02:00
|
|
|
fn then<B>(self, service: B) -> Then<Self, B>
|
|
|
|
where
|
|
|
|
Self: Sized,
|
2019-02-02 04:53:13 +01:00
|
|
|
B: Service<Request = Result<Self::Response, Self::Error>, Error = Self::Error>,
|
2018-10-03 06:47:50 +02:00
|
|
|
{
|
|
|
|
Then::new(self, service)
|
|
|
|
}
|
|
|
|
|
2018-12-09 18:56:23 +01:00
|
|
|
/// 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.
|
2018-08-29 21:20:35 +02:00
|
|
|
fn map<F, R>(self, f: F) -> Map<Self, F, R>
|
|
|
|
where
|
|
|
|
Self: Sized,
|
2019-01-17 00:33:33 +01:00
|
|
|
F: FnMut(Self::Response) -> R,
|
2018-08-29 21:20:35 +02:00
|
|
|
{
|
|
|
|
Map::new(self, f)
|
|
|
|
}
|
|
|
|
|
2018-12-09 18:56:23 +01:00
|
|
|
/// 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.
|
2018-08-29 21:20:35 +02:00
|
|
|
fn map_err<F, E>(self, f: F) -> MapErr<Self, F, E>
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
F: Fn(Self::Error) -> E,
|
|
|
|
{
|
|
|
|
MapErr::new(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-02 04:53:13 +01:00
|
|
|
impl<T: ?Sized> ServiceExt for T where T: Service {}
|
2018-12-13 03:32:19 +01:00
|
|
|
|
2018-11-30 03:56:15 +01:00
|
|
|
/// 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.
|
2019-02-02 04:53:13 +01:00
|
|
|
pub trait NewService {
|
|
|
|
/// Requests handled by the service.
|
|
|
|
type Request;
|
|
|
|
|
2018-11-30 03:56:15 +01:00
|
|
|
/// Responses given by the service
|
|
|
|
type Response;
|
|
|
|
|
|
|
|
/// Errors produced by the service
|
|
|
|
type Error;
|
|
|
|
|
|
|
|
/// The `Service` value created by this factory
|
2019-02-02 04:53:13 +01:00
|
|
|
type Service: Service<
|
|
|
|
Request = Self::Request,
|
|
|
|
Response = Self::Response,
|
|
|
|
Error = Self::Error,
|
|
|
|
>;
|
2018-11-30 03:56:15 +01:00
|
|
|
|
|
|
|
/// Errors produced while building a service.
|
|
|
|
type InitError;
|
|
|
|
|
|
|
|
/// The future of the `Service` instance.
|
|
|
|
type Future: Future<Item = Self::Service, Error = Self::InitError>;
|
|
|
|
|
|
|
|
/// Create and return a new service value asynchronously.
|
|
|
|
fn new_service(&self) -> Self::Future;
|
|
|
|
|
2018-12-09 18:56:23 +01:00
|
|
|
/// Apply function to specified service and use it as a next service in
|
|
|
|
/// chain.
|
2019-02-03 19:42:27 +01:00
|
|
|
fn apply<T, T1, B, B1>(
|
2018-10-30 04:29:47 +01:00
|
|
|
self,
|
2019-02-03 19:42:27 +01:00
|
|
|
transform: T1,
|
|
|
|
service: B1,
|
|
|
|
) -> AndThenTransformNewService<T, Self, B>
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
T: NewTransform<B::Service, Request = Self::Response, InitError = Self::InitError>,
|
|
|
|
T::Error: From<Self::Error>,
|
|
|
|
T1: IntoNewTransform<T, B::Service>,
|
|
|
|
B: NewService<Error = Self::Error, InitError = Self::InitError>,
|
|
|
|
B1: IntoNewService<B>,
|
|
|
|
{
|
|
|
|
AndThenTransformNewService::new(
|
|
|
|
transform.into_new_transform(),
|
|
|
|
self,
|
|
|
|
service.into_new_service(),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Apply function to specified service and use it as a next service in
|
|
|
|
/// chain.
|
|
|
|
fn apply_fn<B, I, F, Out>(self, service: I, f: F) -> AndThenApplyNewService<Self, B, F, Out>
|
2018-08-31 02:46:11 +02:00
|
|
|
where
|
|
|
|
Self: Sized,
|
2019-02-03 19:42:27 +01:00
|
|
|
B: NewService<Error = Self::Error, InitError = Self::InitError>,
|
2019-02-02 04:53:13 +01:00
|
|
|
I: IntoNewService<B>,
|
2019-01-25 04:19:44 +01:00
|
|
|
F: FnMut(Self::Response, &mut B::Service) -> Out,
|
|
|
|
Out: IntoFuture,
|
2019-01-25 05:41:42 +01:00
|
|
|
Out::Error: Into<Self::Error>,
|
2018-08-31 02:46:11 +02:00
|
|
|
{
|
2019-01-25 04:19:44 +01:00
|
|
|
AndThenApplyNewService::new(self, service, f)
|
2018-08-31 02:46:11 +02:00
|
|
|
}
|
|
|
|
|
2018-12-09 18:56:23 +01:00
|
|
|
/// Call another service after call to this one has resolved successfully.
|
2018-08-25 18:02:14 +02:00
|
|
|
fn and_then<F, B>(self, new_service: F) -> AndThenNewService<Self, B>
|
|
|
|
where
|
|
|
|
Self: Sized,
|
2019-02-02 04:53:13 +01:00
|
|
|
F: IntoNewService<B>,
|
|
|
|
B: NewService<
|
|
|
|
Request = Self::Response,
|
|
|
|
Error = Self::Error,
|
|
|
|
InitError = Self::InitError,
|
|
|
|
>,
|
2018-08-25 18:02:14 +02:00
|
|
|
{
|
|
|
|
AndThenNewService::new(self, new_service)
|
|
|
|
}
|
|
|
|
|
2018-12-09 18:56:23 +01:00
|
|
|
/// `NewService` that create service to map this service's error
|
|
|
|
/// and new service's init error to any error
|
|
|
|
/// implementing `From` for this service`s `Error`.
|
|
|
|
///
|
|
|
|
/// Note that this function consumes the receiving new service and returns a
|
|
|
|
/// wrapped version of it.
|
2018-09-18 03:10:23 +02:00
|
|
|
fn from_err<E>(self) -> FromErrNewService<Self, E>
|
|
|
|
where
|
|
|
|
Self: Sized,
|
2018-09-18 03:49:55 +02:00
|
|
|
E: From<Self::Error>,
|
2018-09-18 03:10:23 +02:00
|
|
|
{
|
|
|
|
FromErrNewService::new(self)
|
|
|
|
}
|
|
|
|
|
2018-12-09 18:56:23 +01:00
|
|
|
/// 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.
|
2018-10-03 06:47:50 +02:00
|
|
|
fn then<F, B>(self, new_service: F) -> ThenNewService<Self, B>
|
|
|
|
where
|
|
|
|
Self: Sized,
|
2019-02-02 04:53:13 +01:00
|
|
|
F: IntoNewService<B>,
|
2018-10-03 06:47:50 +02:00
|
|
|
B: NewService<
|
2019-02-02 04:53:13 +01:00
|
|
|
Request = Result<Self::Response, Self::Error>,
|
2018-10-03 06:47:50 +02:00
|
|
|
Error = Self::Error,
|
|
|
|
InitError = Self::InitError,
|
|
|
|
>,
|
|
|
|
{
|
|
|
|
ThenNewService::new(self, new_service)
|
|
|
|
}
|
|
|
|
|
2018-12-09 18:56:23 +01:00
|
|
|
/// Map this service's output to a different type, returning a new service
|
|
|
|
/// of the resulting type.
|
2018-08-28 19:39:27 +02:00
|
|
|
fn map<F, R>(self, f: F) -> MapNewService<Self, F, R>
|
|
|
|
where
|
|
|
|
Self: Sized,
|
2019-01-17 00:33:33 +01:00
|
|
|
F: FnMut(Self::Response) -> R,
|
2018-08-28 19:39:27 +02:00
|
|
|
{
|
|
|
|
MapNewService::new(self, f)
|
|
|
|
}
|
|
|
|
|
2018-12-09 18:56:23 +01:00
|
|
|
/// Map this service's error to a different error, returning a new service.
|
2018-08-25 18:02:14 +02:00
|
|
|
fn map_err<F, E>(self, f: F) -> MapErrNewService<Self, F, E>
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
F: Fn(Self::Error) -> E,
|
|
|
|
{
|
|
|
|
MapErrNewService::new(self, f)
|
|
|
|
}
|
|
|
|
|
2018-12-09 18:56:23 +01:00
|
|
|
/// Map this service's init error to a different error, returning a new service.
|
2018-08-25 18:02:14 +02:00
|
|
|
fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, E>
|
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
F: Fn(Self::InitError) -> E,
|
|
|
|
{
|
|
|
|
MapInitErr::new(self, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-02 04:53:13 +01:00
|
|
|
impl<'a, S> Service for &'a mut S
|
2018-12-09 18:56:23 +01:00
|
|
|
where
|
2019-02-02 04:53:13 +01:00
|
|
|
S: Service + 'a,
|
2018-12-09 18:56:23 +01:00
|
|
|
{
|
2019-02-02 04:53:13 +01:00
|
|
|
type Request = S::Request;
|
2018-12-09 18:56:23 +01:00
|
|
|
type Response = S::Response;
|
|
|
|
type Error = S::Error;
|
|
|
|
type Future = S::Future;
|
|
|
|
|
|
|
|
fn poll_ready(&mut self) -> Poll<(), S::Error> {
|
|
|
|
(**self).poll_ready()
|
|
|
|
}
|
|
|
|
|
2019-02-02 04:53:13 +01:00
|
|
|
fn call(&mut self, request: Self::Request) -> S::Future {
|
2018-12-09 18:56:23 +01:00
|
|
|
(**self).call(request)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-02 04:53:13 +01:00
|
|
|
impl<S> Service for Box<S>
|
2018-12-09 19:14:08 +01:00
|
|
|
where
|
2019-02-02 04:53:13 +01:00
|
|
|
S: Service + ?Sized,
|
2018-12-09 19:14:08 +01:00
|
|
|
{
|
2019-02-02 04:53:13 +01:00
|
|
|
type Request = S::Request;
|
2018-12-09 19:14:08 +01:00
|
|
|
type Response = S::Response;
|
|
|
|
type Error = S::Error;
|
|
|
|
type Future = S::Future;
|
|
|
|
|
|
|
|
fn poll_ready(&mut self) -> Poll<(), S::Error> {
|
|
|
|
(**self).poll_ready()
|
|
|
|
}
|
|
|
|
|
2019-02-02 04:53:13 +01:00
|
|
|
fn call(&mut self, request: Self::Request) -> S::Future {
|
2018-12-09 19:14:08 +01:00
|
|
|
(**self).call(request)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-02 04:53:13 +01:00
|
|
|
impl<F, R, E, S> NewService for F
|
2018-11-30 04:17:02 +01:00
|
|
|
where
|
|
|
|
F: Fn() -> R,
|
|
|
|
R: IntoFuture<Item = S, Error = E>,
|
2019-02-02 04:53:13 +01:00
|
|
|
S: Service,
|
2018-11-30 04:17:02 +01:00
|
|
|
{
|
2019-02-02 04:53:13 +01:00
|
|
|
type Request = S::Request;
|
2018-11-30 04:17:02 +01:00
|
|
|
type Response = S::Response;
|
|
|
|
type Error = S::Error;
|
|
|
|
type Service = S;
|
|
|
|
type InitError = E;
|
|
|
|
type Future = R::Future;
|
|
|
|
|
|
|
|
fn new_service(&self) -> Self::Future {
|
|
|
|
(*self)().into_future()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-04 18:57:47 +02:00
|
|
|
/// Trait for types that can be converted to a `Service`
|
2019-02-02 04:53:13 +01:00
|
|
|
pub trait IntoService<T>
|
2018-09-04 18:49:21 +02:00
|
|
|
where
|
2019-02-02 04:53:13 +01:00
|
|
|
T: Service,
|
2018-09-04 18:49:21 +02:00
|
|
|
{
|
2018-09-04 18:57:47 +02:00
|
|
|
/// Convert to a `Service`
|
2018-09-04 18:49:21 +02:00
|
|
|
fn into_service(self) -> T;
|
|
|
|
}
|
|
|
|
|
2019-02-03 19:42:27 +01:00
|
|
|
/// Trait for types that can be converted to a `NewService`
|
2019-02-02 04:53:13 +01:00
|
|
|
pub trait IntoNewService<T>
|
2018-09-04 18:49:21 +02:00
|
|
|
where
|
2019-02-02 04:53:13 +01:00
|
|
|
T: NewService,
|
2018-09-04 18:49:21 +02:00
|
|
|
{
|
2018-09-04 18:57:47 +02:00
|
|
|
/// Convert to an `NewService`
|
2018-09-04 18:49:21 +02:00
|
|
|
fn into_new_service(self) -> T;
|
|
|
|
}
|
|
|
|
|
2019-02-02 04:53:13 +01:00
|
|
|
impl<T> IntoService<T> for T
|
2018-09-04 18:49:21 +02:00
|
|
|
where
|
2019-02-02 04:53:13 +01:00
|
|
|
T: Service,
|
2018-09-04 18:49:21 +02:00
|
|
|
{
|
|
|
|
fn into_service(self) -> T {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-02 04:53:13 +01:00
|
|
|
impl<T> IntoNewService<T> for T
|
2018-09-04 18:49:21 +02:00
|
|
|
where
|
2019-02-02 04:53:13 +01:00
|
|
|
T: NewService,
|
2018-09-04 18:49:21 +02:00
|
|
|
{
|
|
|
|
fn into_new_service(self) -> T {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|