mirror of https://github.com/fafhrd91/actix-net
remove IntoTransform trait
This commit is contained in:
parent
eb07b5477b
commit
a326878d95
|
@ -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::into::{into_factory, into_service, ServiceFactoryMapper, ServiceMapper};
|
||||||
pub use self::map_config::{map_config, unit_config, MappedConfig};
|
pub use self::map_config::{map_config, unit_config, MappedConfig};
|
||||||
pub use self::pipeline::{pipeline, pipeline_factory, Pipeline, PipelineFactory};
|
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`.
|
/// An asynchronous function from `Request` to a `Response`.
|
||||||
pub trait Service {
|
pub trait Service {
|
||||||
|
|
|
@ -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
|
/// Apply transform to a service. Function returns
|
||||||
/// services factory that in initialization creates
|
/// services factory that in initialization creates
|
||||||
/// service and applies transform to this service.
|
/// service and applies transform to this service.
|
||||||
pub fn apply<T, S, F, U>(
|
pub fn apply<T, S, F, U>(
|
||||||
t: F,
|
t: T,
|
||||||
service: U,
|
service: U,
|
||||||
) -> impl ServiceFactory<
|
) -> impl ServiceFactory<
|
||||||
Config = S::Config,
|
Config = S::Config,
|
||||||
|
@ -118,14 +100,13 @@ pub fn apply<T, S, F, U>(
|
||||||
where
|
where
|
||||||
S: ServiceFactory,
|
S: ServiceFactory,
|
||||||
T: Transform<S::Service, InitError = S::InitError>,
|
T: Transform<S::Service, InitError = S::InitError>,
|
||||||
F: IntoTransform<T, S::Service>,
|
|
||||||
U: IntoServiceFactory<S>,
|
U: IntoServiceFactory<S>,
|
||||||
{
|
{
|
||||||
ApplyTransform::new(t.into_transform(), service.into_factory())
|
ApplyTransform::new(t, service.into_factory())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `Apply` transform to new service
|
/// `Apply` transform to new service
|
||||||
pub struct ApplyTransform<T, S> {
|
struct ApplyTransform<T, S> {
|
||||||
s: Rc<S>,
|
s: Rc<S>,
|
||||||
t: Rc<T>,
|
t: Rc<T>,
|
||||||
}
|
}
|
||||||
|
@ -136,10 +117,10 @@ where
|
||||||
T: Transform<S::Service, InitError = S::InitError>,
|
T: Transform<S::Service, InitError = S::InitError>,
|
||||||
{
|
{
|
||||||
/// Create new `ApplyTransform` new service instance
|
/// 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 {
|
Self {
|
||||||
s: Rc::new(service),
|
s: Rc::new(service),
|
||||||
t: Rc::new(t.into_transform()),
|
t: Rc::new(t),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,8 +156,9 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pin_project]
|
#[pin_project]
|
||||||
pub struct ApplyTransformFuture<T, S>
|
struct ApplyTransformFuture<T, S>
|
||||||
where
|
where
|
||||||
S: ServiceFactory,
|
S: ServiceFactory,
|
||||||
T: Transform<S::Service, InitError = S::InitError>,
|
T: Transform<S::Service, InitError = S::InitError>,
|
||||||
|
|
Loading…
Reference in New Issue