1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-26 19:47:43 +02:00

update utils; add NewTransform::map_init_err

This commit is contained in:
Nikolay Kim
2019-03-02 13:18:01 -08:00
parent d0b8b6940c
commit 668e4f9ac4
10 changed files with 127 additions and 23 deletions

View File

@ -1,4 +1,4 @@
use actix_service::{NewTransform, Service, Transform};
use actix_service::{NewTransform, Service, Transform, Void};
use futures::future::{ok, FutureResult};
use futures::{Async, Future, Poll};
@ -24,15 +24,15 @@ impl Default for InFlight {
}
}
impl<T: Service> NewTransform<T> for InFlight {
impl<T: Service, C> NewTransform<T, C> for InFlight {
type Request = T::Request;
type Response = T::Response;
type Error = T::Error;
type InitError = ();
type InitError = Void;
type Transform = InFlightService;
type Future = FutureResult<Self::Transform, Self::InitError>;
fn new_transform(&self) -> Self::Future {
fn new_transform(&self, _: &C) -> Self::Future {
ok(InFlightService::new(self.max_inflight))
}
}

View File

@ -1,13 +1,12 @@
use std::marker::PhantomData;
use std::time::{Duration, Instant};
use actix_service::{NewService, Service};
use actix_service::{NewService, Service, Void};
use futures::future::{ok, FutureResult};
use futures::{Async, Future, Poll};
use tokio_timer::Delay;
use super::time::{LowResTime, LowResTimeService};
use super::Never;
pub struct KeepAlive<R, E, F> {
f: F,
@ -51,7 +50,7 @@ where
type Request = R;
type Response = R;
type Error = E;
type InitError = Never;
type InitError = Void;
type Service = KeepAliveService<R, E, F>;
type Future = FutureResult<Self::Service, Self::InitError>;

View File

@ -3,7 +3,7 @@ use std::fmt;
use std::marker::PhantomData;
use std::rc::Rc;
use actix_service::{NewTransform, Service, Transform};
use actix_service::{NewTransform, Service, Transform, Void};
use futures::future::{ok, FutureResult};
use futures::task::AtomicTask;
use futures::unsync::oneshot;
@ -85,7 +85,7 @@ where
}
}
impl<S> NewTransform<S> for InOrder<S>
impl<S, C> NewTransform<S, C> for InOrder<S>
where
S: Service,
S::Response: 'static,
@ -95,11 +95,11 @@ where
type Request = S::Request;
type Response = S::Response;
type Error = InOrderError<S::Error>;
type InitError = ();
type InitError = Void;
type Transform = InOrderService<S>;
type Future = FutureResult<Self::Transform, Self::InitError>;
fn new_transform(&self) -> Self::Future {
fn new_transform(&self, _: &C) -> Self::Future {
ok(InOrderService::new())
}
}

View File

@ -1,12 +1,11 @@
use std::time::{self, Duration, Instant};
use actix_service::{NewService, Service};
use actix_service::{NewService, Service, Void};
use futures::future::{ok, FutureResult};
use futures::{Async, Future, Poll};
use tokio_timer::sleep;
use super::cell::Cell;
use super::Never;
#[derive(Clone, Debug)]
pub struct LowResTime(Cell<Inner>);
@ -45,8 +44,8 @@ impl Default for LowResTime {
impl NewService<()> for LowResTime {
type Request = ();
type Response = Instant;
type Error = Never;
type InitError = Never;
type Error = Void;
type InitError = Void;
type Service = LowResTimeService;
type Future = FutureResult<Self::Service, Self::InitError>;
@ -92,7 +91,7 @@ impl LowResTimeService {
impl Service for LowResTimeService {
type Request = ();
type Response = Instant;
type Error = Never;
type Error = Void;
type Future = FutureResult<Self::Response, Self::Error>;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {

View File

@ -80,7 +80,7 @@ impl<E> Clone for Timeout<E> {
}
}
impl<S, E> NewTransform<S> for Timeout<E>
impl<S, C, E> NewTransform<S, C> for Timeout<E>
where
S: Service,
{
@ -91,7 +91,7 @@ where
type Transform = TimeoutService;
type Future = FutureResult<Self::Transform, Self::InitError>;
fn new_transform(&self) -> Self::Future {
fn new_transform(&self, _: &C) -> Self::Future {
ok(TimeoutService {
timeout: self.timeout,
})