mirror of
https://github.com/fafhrd91/actix-net
synced 2025-01-18 06:11:50 +01:00
use IntoService types for transform services
This commit is contained in:
parent
825117fd4c
commit
755d4958c5
@ -1,5 +1,11 @@
|
||||
# Changes
|
||||
|
||||
## [0.3.4] - 2019-03-12
|
||||
|
||||
### Changed
|
||||
|
||||
* `TimeoutService`, `InOrderService`, `InFlightService` accepts generic IntoService services.
|
||||
|
||||
## [0.3.3] - 2019-03-09
|
||||
|
||||
### Changed
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "actix-utils"
|
||||
version = "0.3.3"
|
||||
version = "0.3.4"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
description = "Actix utils - various actix net related services"
|
||||
keywords = ["network", "framework", "async", "futures"]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use actix_service::{Service, Transform, Void};
|
||||
use actix_service::{IntoService, Service, Transform, Void};
|
||||
use futures::future::{ok, FutureResult};
|
||||
use futures::{Async, Future, Poll};
|
||||
|
||||
@ -42,11 +42,17 @@ pub struct InFlightService<S> {
|
||||
service: S,
|
||||
}
|
||||
|
||||
impl<S> InFlightService<S> {
|
||||
pub fn new(max: usize, service: S) -> Self {
|
||||
impl<S> InFlightService<S>
|
||||
where
|
||||
S: Service,
|
||||
{
|
||||
pub fn new<U>(max: usize, service: U) -> Self
|
||||
where
|
||||
U: IntoService<S>,
|
||||
{
|
||||
Self {
|
||||
service,
|
||||
count: Counter::new(max),
|
||||
service: service.into_service(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use std::fmt;
|
||||
use std::marker::PhantomData;
|
||||
use std::rc::Rc;
|
||||
|
||||
use actix_service::{Service, Transform, Void};
|
||||
use actix_service::{IntoService, Service, Transform, Void};
|
||||
use futures::future::{ok, FutureResult};
|
||||
use futures::task::AtomicTask;
|
||||
use futures::unsync::oneshot;
|
||||
@ -112,9 +112,12 @@ where
|
||||
S::Future: 'static,
|
||||
S::Error: 'static,
|
||||
{
|
||||
pub fn new(service: S) -> Self {
|
||||
pub fn new<U>(service: U) -> Self
|
||||
where
|
||||
U: IntoService<S>,
|
||||
{
|
||||
Self {
|
||||
service,
|
||||
service: service.into_service(),
|
||||
acks: VecDeque::new(),
|
||||
task: Rc::new(AtomicTask::new()),
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use std::fmt;
|
||||
use std::marker::PhantomData;
|
||||
use std::time::Duration;
|
||||
|
||||
use actix_service::{Service, Transform};
|
||||
use actix_service::{IntoService, Service, Transform};
|
||||
use futures::future::{ok, FutureResult};
|
||||
use futures::{Async, Future, Poll};
|
||||
use tokio_timer::{clock, Delay};
|
||||
@ -106,9 +106,18 @@ pub struct TimeoutService<S> {
|
||||
timeout: Duration,
|
||||
}
|
||||
|
||||
impl<S> TimeoutService<S> {
|
||||
pub fn new(timeout: Duration, service: S) -> Self {
|
||||
TimeoutService { service, timeout }
|
||||
impl<S> TimeoutService<S>
|
||||
where
|
||||
S: Service,
|
||||
{
|
||||
pub fn new<U>(timeout: Duration, service: U) -> Self
|
||||
where
|
||||
U: IntoService<S>,
|
||||
{
|
||||
TimeoutService {
|
||||
timeout,
|
||||
service: service.into_service(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user