Browse Source

add extra constraints

master
Nikolay Kim 7 months ago
parent
commit
e66312b664
5 changed files with 12 additions and 18 deletions
  1. +4
    -4
      Cargo.toml
  2. +5
    -11
      actix-http/src/cloneable.rs
  3. +1
    -1
      actix-http/src/h1/service.rs
  4. +1
    -1
      actix-http/src/h2/service.rs
  5. +1
    -1
      actix-http/src/service.rs

+ 4
- 4
Cargo.toml 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"
@@ -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" }

+ 5
- 11
actix-http/src/cloneable.rs 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;


+ 1
- 1
actix-http/src/h1/service.rs 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>>,


+ 1
- 1
actix-http/src/h2/service.rs 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>>>,


+ 1
- 1
actix-http/src/service.rs 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>>,


Loading…
Cancel
Save