1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-28 20:10:35 +02: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,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