From a326878d95bdb2cec442eaf76a6c28d9b6e535b1 Mon Sep 17 00:00:00 2001 From: Nikolay Kim <fafhrd91@gmail.com> Date: Thu, 14 Nov 2019 05:00:23 +0600 Subject: [PATCH] remove IntoTransform trait --- actix-service/src/lib.rs | 2 +- actix-service/src/transform.rs | 32 +++++++------------------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/actix-service/src/lib.rs b/actix-service/src/lib.rs index 7661915b..16162563 100644 --- a/actix-service/src/lib.rs +++ b/actix-service/src/lib.rs @@ -26,7 +26,7 @@ pub use self::fn_service::{factory_fn, factory_fn_cfg, service_fn, service_fn2}; pub use self::into::{into_factory, into_service, ServiceFactoryMapper, ServiceMapper}; pub use self::map_config::{map_config, unit_config, MappedConfig}; pub use self::pipeline::{pipeline, pipeline_factory, Pipeline, PipelineFactory}; -pub use self::transform::{apply, IntoTransform, Transform}; +pub use self::transform::{apply, Transform}; /// An asynchronous function from `Request` to a `Response`. pub trait Service { diff --git a/actix-service/src/transform.rs b/actix-service/src/transform.rs index 3dc398f2..e90836f5 100644 --- a/actix-service/src/transform.rs +++ b/actix-service/src/transform.rs @@ -83,29 +83,11 @@ where } } -/// Trait for types that can be converted to a *transform service* -pub trait IntoTransform<T, S> -where - T: Transform<S>, -{ - /// Convert to a `TransformService` - fn into_transform(self) -> T; -} - -impl<T, S> IntoTransform<T, S> for T -where - T: Transform<S>, -{ - fn into_transform(self) -> T { - self - } -} - /// Apply transform to a service. Function returns /// services factory that in initialization creates /// service and applies transform to this service. pub fn apply<T, S, F, U>( - t: F, + t: T, service: U, ) -> impl ServiceFactory< Config = S::Config, @@ -118,14 +100,13 @@ pub fn apply<T, S, F, U>( where S: ServiceFactory, T: Transform<S::Service, InitError = S::InitError>, - F: IntoTransform<T, S::Service>, U: IntoServiceFactory<S>, { - ApplyTransform::new(t.into_transform(), service.into_factory()) + ApplyTransform::new(t, service.into_factory()) } /// `Apply` transform to new service -pub struct ApplyTransform<T, S> { +struct ApplyTransform<T, S> { s: Rc<S>, t: Rc<T>, } @@ -136,10 +117,10 @@ where T: Transform<S::Service, InitError = S::InitError>, { /// Create new `ApplyTransform` new service instance - pub fn new<F: IntoTransform<T, S::Service>>(t: F, service: S) -> Self { + fn new(t: T, service: S) -> Self { Self { s: Rc::new(service), - t: Rc::new(t.into_transform()), + t: Rc::new(t), } } } @@ -175,8 +156,9 @@ where } } } + #[pin_project] -pub struct ApplyTransformFuture<T, S> +struct ApplyTransformFuture<T, S> where S: ServiceFactory, T: Transform<S::Service, InitError = S::InitError>,