1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-12-03 20:02:12 +01:00

add extra constraints

This commit is contained in:
Nikolay Kim 2020-01-10 11:36:59 +06:00
parent 39f4b2b39e
commit e66312b664
5 changed files with 12 additions and 18 deletions

View File

@ -60,9 +60,9 @@ rustls = ["actix-tls/rustls", "awc/rustls", "rust-tls"]
[dependencies]
actix-codec = "0.2.0"
actix-service = "1.0.1"
actix-utils = "1.0.4"
actix-router = "0.2.1"
actix-service = "1.0.2"
actix-utils = "1.0.6"
actix-router = "0.2.4"
actix-rt = "1.0.0"
actix-server = "1.0.0"
actix-testing = "1.0.0"

View File

@ -6,27 +6,21 @@ use actix_service::Service;
#[doc(hidden)]
/// Service that allows to turn non-clone service to a service with `Clone` impl
pub(crate) struct CloneableService<T>(Rc<UnsafeCell<T>>);
pub(crate) struct CloneableService<T: Service>(Rc<UnsafeCell<T>>);
impl<T> CloneableService<T> {
pub(crate) fn new(service: T) -> Self
where
T: Service,
{
impl<T: Service> CloneableService<T> {
pub(crate) fn new(service: T) -> Self {
Self(Rc::new(UnsafeCell::new(service)))
}
}
impl<T> Clone for CloneableService<T> {
impl<T: Service> Clone for CloneableService<T> {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl<T> Service for CloneableService<T>
where
T: Service,
{
impl<T: Service> Service for CloneableService<T> {
type Request = T::Request;
type Response = T::Response;
type Error = T::Error;

View File

@ -364,7 +364,7 @@ where
}
/// `Service` implementation for HTTP1 transport
pub struct H1ServiceHandler<T, S, B, X, U> {
pub struct H1ServiceHandler<T, S: Service, B, X: Service, U: Service> {
srv: CloneableService<S>,
expect: CloneableService<X>,
upgrade: Option<CloneableService<U>>,

View File

@ -246,7 +246,7 @@ where
}
/// `Service` implementation for http/2 transport
pub struct H2ServiceHandler<T, S, B> {
pub struct H2ServiceHandler<T, S: Service, B> {
srv: CloneableService<S>,
cfg: ServiceConfig,
on_connect: Option<rc::Rc<dyn Fn(&T) -> Box<dyn DataFactory>>>,

View File

@ -443,7 +443,7 @@ where
}
/// `Service` implementation for http transport
pub struct HttpServiceHandler<T, S, B, X, U> {
pub struct HttpServiceHandler<T, S: Service, B, X: Service, U: Service> {
srv: CloneableService<S>,
expect: CloneableService<X>,
upgrade: Option<CloneableService<U>>,