mirror of
https://github.com/fafhrd91/actix-net
synced 2025-08-20 06:25:37 +02:00
revert generic Request change
This commit is contained in:
@@ -5,23 +5,24 @@ use futures::{Async, Future, IntoFuture, Poll};
|
||||
use super::{IntoNewService, IntoService, NewService, Service};
|
||||
|
||||
/// `Apply` service combinator
|
||||
pub struct Apply<T, R, F, In, Out> {
|
||||
pub struct Apply<T, F, In, Out>
|
||||
where
|
||||
T: Service,
|
||||
{
|
||||
service: T,
|
||||
f: F,
|
||||
r: PhantomData<(R, In, Out)>,
|
||||
r: PhantomData<(In, Out)>,
|
||||
}
|
||||
|
||||
impl<T, R, F, In, Out> Apply<T, R, F, In, Out>
|
||||
impl<T, F, In, Out> Apply<T, F, In, Out>
|
||||
where
|
||||
T: Service,
|
||||
F: FnMut(In, &mut T) -> Out,
|
||||
Out: IntoFuture,
|
||||
Out::Error: From<T::Error>,
|
||||
{
|
||||
/// Create new `Apply` combinator
|
||||
pub fn new<I: IntoService<T, R>>(service: I, f: F) -> Self
|
||||
where
|
||||
T: Service<R>,
|
||||
Out: IntoFuture,
|
||||
Out::Error: From<T::Error>,
|
||||
{
|
||||
pub fn new<I: IntoService<T>>(service: I, f: F) -> Self {
|
||||
Self {
|
||||
service: service.into_service(),
|
||||
f,
|
||||
@@ -30,9 +31,9 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, R, F, In, Out> Clone for Apply<T, R, F, In, Out>
|
||||
impl<T, F, In, Out> Clone for Apply<T, F, In, Out>
|
||||
where
|
||||
T: Clone,
|
||||
T: Service + Clone,
|
||||
F: Clone,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
@@ -44,13 +45,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, R, F, In, Out> Service<In> for Apply<T, R, F, In, Out>
|
||||
impl<T, F, In, Out> Service for Apply<T, F, In, Out>
|
||||
where
|
||||
T: Service<R>,
|
||||
T: Service,
|
||||
F: FnMut(In, &mut T) -> Out,
|
||||
Out: IntoFuture,
|
||||
Out::Error: From<T::Error>,
|
||||
{
|
||||
type Request = In;
|
||||
type Response = Out::Item;
|
||||
type Error = Out::Error;
|
||||
type Future = Out::Future;
|
||||
@@ -65,21 +67,24 @@ where
|
||||
}
|
||||
|
||||
/// `ApplyNewService` new service combinator
|
||||
pub struct ApplyNewService<T, F, In, Out, Req> {
|
||||
pub struct ApplyNewService<T, F, In, Out, Cfg>
|
||||
where
|
||||
T: NewService<Cfg>,
|
||||
{
|
||||
service: T,
|
||||
f: F,
|
||||
r: PhantomData<(In, Out, Req)>,
|
||||
r: PhantomData<(In, Out, Cfg)>,
|
||||
}
|
||||
|
||||
impl<T, F, In, Out, Req> ApplyNewService<T, F, In, Out, Req> {
|
||||
impl<T, F, In, Out, Cfg> ApplyNewService<T, F, In, Out, Cfg>
|
||||
where
|
||||
T: NewService<Cfg>,
|
||||
F: FnMut(In, &mut T::Service) -> Out + Clone,
|
||||
Out: IntoFuture,
|
||||
Out::Error: From<T::Error>,
|
||||
{
|
||||
/// Create new `ApplyNewService` new service instance
|
||||
pub fn new<Cfg, F1: IntoNewService<T, Req, Cfg>>(service: F1, f: F) -> Self
|
||||
where
|
||||
T: NewService<Req, Cfg>,
|
||||
F: FnMut(In, &mut T::Service) -> Out + Clone,
|
||||
Out: IntoFuture,
|
||||
Out::Error: From<T::Error>,
|
||||
{
|
||||
pub fn new<F1: IntoNewService<T, Cfg>>(service: F1, f: F) -> Self {
|
||||
Self {
|
||||
f,
|
||||
service: service.into_new_service(),
|
||||
@@ -88,10 +93,11 @@ impl<T, F, In, Out, Req> ApplyNewService<T, F, In, Out, Req> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, F, In, Out, Req> Clone for ApplyNewService<T, F, In, Out, Req>
|
||||
impl<T, F, In, Out, Cfg> Clone for ApplyNewService<T, F, In, Out, Cfg>
|
||||
where
|
||||
T: Clone,
|
||||
F: Clone,
|
||||
T: NewService<Cfg> + Clone,
|
||||
F: FnMut(In, &mut T::Service) -> Out + Clone,
|
||||
Out: IntoFuture,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
@@ -102,28 +108,29 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, F, In, Out, Req, Cfg> NewService<In, Cfg> for ApplyNewService<T, F, In, Out, Req>
|
||||
impl<T, F, In, Out, Cfg> NewService<Cfg> for ApplyNewService<T, F, In, Out, Cfg>
|
||||
where
|
||||
T: NewService<Req, Cfg>,
|
||||
T: NewService<Cfg>,
|
||||
F: FnMut(In, &mut T::Service) -> Out + Clone,
|
||||
Out: IntoFuture,
|
||||
Out::Error: From<T::Error>,
|
||||
{
|
||||
type Request = In;
|
||||
type Response = Out::Item;
|
||||
type Error = Out::Error;
|
||||
type Service = Apply<T::Service, Req, F, In, Out>;
|
||||
type Service = Apply<T::Service, F, In, Out>;
|
||||
|
||||
type InitError = T::InitError;
|
||||
type Future = ApplyNewServiceFuture<T, F, In, Out, Req, Cfg>;
|
||||
type Future = ApplyNewServiceFuture<T, F, In, Out, Cfg>;
|
||||
|
||||
fn new_service(&self, cfg: &Cfg) -> Self::Future {
|
||||
ApplyNewServiceFuture::new(self.service.new_service(cfg), self.f.clone())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ApplyNewServiceFuture<T, F, In, Out, Req, Cfg>
|
||||
pub struct ApplyNewServiceFuture<T, F, In, Out, Cfg>
|
||||
where
|
||||
T: NewService<Req, Cfg>,
|
||||
T: NewService<Cfg>,
|
||||
F: FnMut(In, &mut T::Service) -> Out + Clone,
|
||||
Out: IntoFuture,
|
||||
{
|
||||
@@ -132,9 +139,9 @@ where
|
||||
r: PhantomData<(In, Out)>,
|
||||
}
|
||||
|
||||
impl<T, F, In, Out, Req, Cfg> ApplyNewServiceFuture<T, F, In, Out, Req, Cfg>
|
||||
impl<T, F, In, Out, Cfg> ApplyNewServiceFuture<T, F, In, Out, Cfg>
|
||||
where
|
||||
T: NewService<Req, Cfg>,
|
||||
T: NewService<Cfg>,
|
||||
F: FnMut(In, &mut T::Service) -> Out + Clone,
|
||||
Out: IntoFuture,
|
||||
{
|
||||
@@ -147,14 +154,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, F, In, Out, Req, Cfg> Future for ApplyNewServiceFuture<T, F, In, Out, Req, Cfg>
|
||||
impl<T, F, In, Out, Cfg> Future for ApplyNewServiceFuture<T, F, In, Out, Cfg>
|
||||
where
|
||||
T: NewService<Req, Cfg>,
|
||||
T: NewService<Cfg>,
|
||||
F: FnMut(In, &mut T::Service) -> Out + Clone,
|
||||
Out: IntoFuture,
|
||||
Out::Error: From<T::Error>,
|
||||
{
|
||||
type Item = Apply<T::Service, Req, F, In, Out>;
|
||||
type Item = Apply<T::Service, F, In, Out>;
|
||||
type Error = T::InitError;
|
||||
|
||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||
@@ -176,7 +183,8 @@ mod tests {
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Srv;
|
||||
impl Service<()> for Srv {
|
||||
impl Service for Srv {
|
||||
type Request = ();
|
||||
type Response = ();
|
||||
type Error = ();
|
||||
type Future = FutureResult<(), ()>;
|
||||
|
Reference in New Issue
Block a user