Skip to content

Commit

Permalink
add extra constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Jan 10, 2020
1 parent 39f4b2b commit e66312b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -115,4 +115,4 @@ actix-identity = { path = "actix-identity" }
actix-session = { path = "actix-session" }
actix-files = { path = "actix-files" }
actix-multipart = { path = "actix-multipart" }
awc = { path = "awc" }
awc = { path = "awc" }
16 changes: 5 additions & 11 deletions actix-http/src/cloneable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion actix-http/src/h1/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>,
Expand Down
2 changes: 1 addition & 1 deletion actix-http/src/h2/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>>,
Expand Down
2 changes: 1 addition & 1 deletion actix-http/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>,
Expand Down

0 comments on commit e66312b

Please sign in to comment.