mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-30 18:44:35 +01:00
remove two unused generics on BoxedRouteFuture types. (#1820)
This commit is contained in:
parent
ff79c33fd4
commit
7a3776b770
42
src/route.rs
42
src/route.rs
@ -16,24 +16,24 @@ use crate::responder::Responder;
|
|||||||
use crate::service::{ServiceRequest, ServiceResponse};
|
use crate::service::{ServiceRequest, ServiceResponse};
|
||||||
use crate::HttpResponse;
|
use crate::HttpResponse;
|
||||||
|
|
||||||
type BoxedRouteService<Req, Res> = Box<
|
type BoxedRouteService = Box<
|
||||||
dyn Service<
|
dyn Service<
|
||||||
Request = Req,
|
Request = ServiceRequest,
|
||||||
Response = Res,
|
Response = ServiceResponse,
|
||||||
Error = Error,
|
Error = Error,
|
||||||
Future = LocalBoxFuture<'static, Result<Res, Error>>,
|
Future = LocalBoxFuture<'static, Result<ServiceResponse, Error>>,
|
||||||
>,
|
>,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
type BoxedRouteNewService<Req, Res> = Box<
|
type BoxedRouteNewService = Box<
|
||||||
dyn ServiceFactory<
|
dyn ServiceFactory<
|
||||||
Config = (),
|
Config = (),
|
||||||
Request = Req,
|
Request = ServiceRequest,
|
||||||
Response = Res,
|
Response = ServiceResponse,
|
||||||
Error = Error,
|
Error = Error,
|
||||||
InitError = (),
|
InitError = (),
|
||||||
Service = BoxedRouteService<Req, Res>,
|
Service = BoxedRouteService,
|
||||||
Future = LocalBoxFuture<'static, Result<BoxedRouteService<Req, Res>, ()>>,
|
Future = LocalBoxFuture<'static, Result<BoxedRouteService, ()>>,
|
||||||
>,
|
>,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ type BoxedRouteNewService<Req, Res> = Box<
|
|||||||
/// Route uses builder-like pattern for configuration.
|
/// Route uses builder-like pattern for configuration.
|
||||||
/// If handler is not explicitly set, default *404 Not Found* handler is used.
|
/// If handler is not explicitly set, default *404 Not Found* handler is used.
|
||||||
pub struct Route {
|
pub struct Route {
|
||||||
service: BoxedRouteNewService<ServiceRequest, ServiceResponse>,
|
service: BoxedRouteNewService,
|
||||||
guards: Rc<Vec<Box<dyn Guard>>>,
|
guards: Rc<Vec<Box<dyn Guard>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,15 +80,8 @@ impl ServiceFactory for Route {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type RouteFuture = LocalBoxFuture<
|
|
||||||
'static,
|
|
||||||
Result<BoxedRouteService<ServiceRequest, ServiceResponse>, ()>,
|
|
||||||
>;
|
|
||||||
|
|
||||||
#[pin_project::pin_project]
|
|
||||||
pub struct CreateRouteService {
|
pub struct CreateRouteService {
|
||||||
#[pin]
|
fut: LocalBoxFuture<'static, Result<BoxedRouteService, ()>>,
|
||||||
fut: RouteFuture,
|
|
||||||
guards: Rc<Vec<Box<dyn Guard>>>,
|
guards: Rc<Vec<Box<dyn Guard>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,9 +89,9 @@ impl Future for CreateRouteService {
|
|||||||
type Output = Result<RouteService, ()>;
|
type Output = Result<RouteService, ()>;
|
||||||
|
|
||||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
let this = self.project();
|
let this = self.get_mut();
|
||||||
|
|
||||||
match this.fut.poll(cx)? {
|
match this.fut.as_mut().poll(cx)? {
|
||||||
Poll::Ready(service) => Poll::Ready(Ok(RouteService {
|
Poll::Ready(service) => Poll::Ready(Ok(RouteService {
|
||||||
service,
|
service,
|
||||||
guards: this.guards.clone(),
|
guards: this.guards.clone(),
|
||||||
@ -109,7 +102,7 @@ impl Future for CreateRouteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct RouteService {
|
pub struct RouteService {
|
||||||
service: BoxedRouteService<ServiceRequest, ServiceResponse>,
|
service: BoxedRouteService,
|
||||||
guards: Rc<Vec<Box<dyn Guard>>>,
|
guards: Rc<Vec<Box<dyn Guard>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,12 +268,12 @@ where
|
|||||||
T::Service: 'static,
|
T::Service: 'static,
|
||||||
<T::Service as Service>::Future: 'static,
|
<T::Service as Service>::Future: 'static,
|
||||||
{
|
{
|
||||||
type Config = ();
|
|
||||||
type Request = ServiceRequest;
|
type Request = ServiceRequest;
|
||||||
type Response = ServiceResponse;
|
type Response = ServiceResponse;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
type Config = ();
|
||||||
|
type Service = BoxedRouteService;
|
||||||
type InitError = ();
|
type InitError = ();
|
||||||
type Service = BoxedRouteService<ServiceRequest, Self::Response>;
|
|
||||||
type Future = LocalBoxFuture<'static, Result<Self::Service, Self::InitError>>;
|
type Future = LocalBoxFuture<'static, Result<Self::Service, Self::InitError>>;
|
||||||
|
|
||||||
fn new_service(&self, _: ()) -> Self::Future {
|
fn new_service(&self, _: ()) -> Self::Future {
|
||||||
@ -288,8 +281,7 @@ where
|
|||||||
.new_service(())
|
.new_service(())
|
||||||
.map(|result| match result {
|
.map(|result| match result {
|
||||||
Ok(service) => {
|
Ok(service) => {
|
||||||
let service: BoxedRouteService<_, _> =
|
let service = Box::new(RouteServiceWrapper { service }) as _;
|
||||||
Box::new(RouteServiceWrapper { service });
|
|
||||||
Ok(service)
|
Ok(service)
|
||||||
}
|
}
|
||||||
Err(_) => Err(()),
|
Err(_) => Err(()),
|
||||||
|
Loading…
Reference in New Issue
Block a user