1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-23 22:51:07 +01:00

add NewService impls for Rc<S> and Arc<S>

This commit is contained in:
Nikolay Kim 2019-02-19 11:31:54 -08:00
parent 32f4718880
commit 3d7daabdd7
3 changed files with 45 additions and 1 deletions

View File

@ -1,5 +1,14 @@
# Changes
## [0.2.2] - 2019-02-19
### Added
* Added `NewService` impl for `Rc<S> where S: NewService`
* Added `NewService` impl for `Arc<S> where S: NewService`
## [0.2.1] - 2019-02-03
### Changed

View File

@ -1,6 +1,6 @@
[package]
name = "actix-service"
version = "0.2.1"
version = "0.2.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix Service"
keywords = ["network", "framework", "async", "futures"]

View File

@ -1,3 +1,6 @@
use std::rc::Rc;
use std::sync::Arc;
use futures::{Future, IntoFuture, Poll};
mod and_then;
@ -377,6 +380,38 @@ where
}
}
impl<S> NewService for Rc<S>
where
S: NewService,
{
type Request = S::Request;
type Response = S::Response;
type Error = S::Error;
type Service = S::Service;
type InitError = S::InitError;
type Future = S::Future;
fn new_service(&self) -> S::Future {
self.as_ref().new_service()
}
}
impl<S> NewService for Arc<S>
where
S: NewService,
{
type Request = S::Request;
type Response = S::Response;
type Error = S::Error;
type Service = S::Service;
type InitError = S::InitError;
type Future = S::Future;
fn new_service(&self) -> S::Future {
self.as_ref().new_service()
}
}
/// Trait for types that can be converted to a `Service`
pub trait IntoService<T>
where