1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-27 17:22:57 +01:00

cleanup deprecation warning for Box<dyn>

This commit is contained in:
Nikolay Kim 2019-07-17 11:44:39 +06:00
parent c65dbaf88e
commit 7b1dcaffda
20 changed files with 59 additions and 54 deletions

View File

@ -681,7 +681,7 @@ where
type Error = Error;
type Future = Either<
FutureResult<Self::Response, Error>,
Either<S::Future, Box<Future<Item = Self::Response, Error = Error>>>,
Either<S::Future, Box<dyn Future<Item = Self::Response, Error = Error>>>,
>;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {

View File

@ -50,7 +50,7 @@ pub struct ChunkedReadFile {
size: u64,
offset: u64,
file: Option<File>,
fut: Option<Box<Future<Item = (File, Bytes), Error = BlockingError<io::Error>>>>,
fut: Option<Box<dyn Future<Item = (File, Bytes), Error = BlockingError<io::Error>>>>,
counter: u64,
}
@ -370,7 +370,7 @@ impl NewService for Files {
type Error = Error;
type Service = FilesService;
type InitError = ();
type Future = Box<Future<Item = Self::Service, Error = Self::InitError>>;
type Future = Box<dyn Future<Item = Self::Service, Error = Self::InitError>>;
fn new_service(&self, _: &()) -> Self::Future {
let mut srv = FilesService {
@ -416,7 +416,7 @@ impl FilesService {
req: ServiceRequest,
) -> Either<
FutureResult<ServiceResponse, Error>,
Box<Future<Item = ServiceResponse, Error = Error>>,
Box<dyn Future<Item = ServiceResponse, Error = Error>>,
> {
log::debug!("Files: Failed to handle {}: {}", req.path(), e);
if let Some(ref mut default) = self.default {
@ -433,7 +433,7 @@ impl Service for FilesService {
type Error = Error;
type Future = Either<
FutureResult<Self::Response, Self::Error>,
Box<Future<Item = Self::Response, Error = Self::Error>>,
Box<dyn Future<Item = Self::Response, Error = Self::Error>>,
>;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {

View File

@ -13,7 +13,7 @@ use crate::helpers::{BoxedHttpNewService, BoxedHttpService, HttpNewService};
use crate::request::FramedRequest;
use crate::state::State;
type BoxedResponse = Box<Future<Item = (), Error = Error>>;
type BoxedResponse = Box<dyn Future<Item = (), Error = Error>>;
pub trait HttpServiceFactory {
type Factory: NewService;
@ -61,7 +61,7 @@ impl<T: 'static, S: 'static> FramedApp<T, S> {
Request = FramedRequest<T, S>,
Response = (),
Error = Error,
Future = Box<Future<Item = (), Error = Error>>,
Future = Box<dyn Future<Item = (), Error = Error>>,
>,
{
let path = factory.path().to_string();
@ -129,7 +129,7 @@ pub struct CreateService<T, S> {
enum CreateServiceItem<T, S> {
Future(
Option<String>,
Box<Future<Item = BoxedHttpService<FramedRequest<T, S>>, Error = ()>>,
Box<dyn Future<Item = BoxedHttpService<FramedRequest<T, S>>, Error = ()>>,
),
Service(String, BoxedHttpService<FramedRequest<T, S>>),
}

View File

@ -7,7 +7,7 @@ pub(crate) type BoxedHttpService<Req> = Box<
Request = Req,
Response = (),
Error = Error,
Future = Box<Future<Item = (), Error = Error>>,
Future = Box<dyn Future<Item = (), Error = Error>>,
>,
>;
@ -19,7 +19,7 @@ pub(crate) type BoxedHttpNewService<Req> = Box<
Error = Error,
InitError = (),
Service = BoxedHttpService<Req>,
Future = Box<Future<Item = BoxedHttpService<Req>, Error = ()>>,
Future = Box<dyn Future<Item = BoxedHttpService<Req>, Error = ()>>,
>,
>;
@ -30,7 +30,7 @@ where
T: NewService<Response = (), Error = Error>,
T::Response: 'static,
T::Future: 'static,
T::Service: Service<Future = Box<Future<Item = (), Error = Error>>> + 'static,
T::Service: Service<Future = Box<dyn Future<Item = (), Error = Error>>> + 'static,
<T::Service as Service>::Future: 'static,
{
pub fn new(service: T) -> Self {
@ -43,7 +43,7 @@ where
T: NewService<Config = (), Response = (), Error = Error>,
T::Request: 'static,
T::Future: 'static,
T::Service: Service<Future = Box<Future<Item = (), Error = Error>>> + 'static,
T::Service: Service<Future = Box<dyn Future<Item = (), Error = Error>>> + 'static,
<T::Service as Service>::Future: 'static,
{
type Config = ();
@ -52,7 +52,7 @@ where
type Error = Error;
type InitError = ();
type Service = BoxedHttpService<T::Request>;
type Future = Box<Future<Item = Self::Service, Error = ()>>;
type Future = Box<dyn Future<Item = Self::Service, Error = ()>>;
fn new_service(&self, _: &()) -> Self::Future {
Box::new(self.0.new_service(&()).map_err(|_| ()).and_then(|service| {
@ -70,7 +70,7 @@ impl<T> Service for HttpServiceWrapper<T>
where
T: Service<
Response = (),
Future = Box<Future<Item = (), Error = Error>>,
Future = Box<dyn Future<Item = (), Error = Error>>,
Error = Error,
>,
T::Request: 'static,
@ -78,7 +78,7 @@ where
type Request = T::Request;
type Response = ();
type Error = Error;
type Future = Box<Future<Item = (), Error = Error>>;
type Future = Box<dyn Future<Item = (), Error = Error>>;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
self.service.poll_ready()

View File

@ -140,7 +140,7 @@ where
type Request = FramedRequest<Io, S>;
type Response = ();
type Error = Error;
type Future = Box<Future<Item = (), Error = Error>>;
type Future = Box<dyn Future<Item = (), Error = Error>>;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
Ok(Async::Ready(()))

View File

@ -94,7 +94,8 @@ where
T: AsyncRead + AsyncWrite + 'static,
{
type Io = T;
type Future = Box<Future<Item = (ResponseHead, Payload), Error = SendRequestError>>;
type Future =
Box<dyn Future<Item = (ResponseHead, Payload), Error = SendRequestError>>;
fn protocol(&self) -> Protocol {
match self.io {
@ -169,7 +170,8 @@ where
B: AsyncRead + AsyncWrite + 'static,
{
type Io = EitherIo<A, B>;
type Future = Box<Future<Item = (ResponseHead, Payload), Error = SendRequestError>>;
type Future =
Box<dyn Future<Item = (ResponseHead, Payload), Error = SendRequestError>>;
fn protocol(&self) -> Protocol {
match self {

View File

@ -261,7 +261,7 @@ where
type Request = ServiceRequest;
type Response = ServiceResponse<B>;
type Error = Error;
type Future = Box<Future<Item = Self::Response, Error = Self::Error>>;
type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error>>;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
self.service.borrow_mut().poll_ready()

View File

@ -309,7 +309,7 @@ where
type Request = ServiceRequest;
type Response = ServiceResponse<B>;
type Error = S::Error;
type Future = Box<Future<Item = Self::Response, Error = Self::Error>>;
type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error>>;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
self.service.poll_ready()

View File

@ -20,7 +20,7 @@ pub(crate) trait Connect {
head: RequestHead,
body: Body,
addr: Option<net::SocketAddr>,
) -> Box<Future<Item = ClientResponse, Error = SendRequestError>>;
) -> Box<dyn Future<Item = ClientResponse, Error = SendRequestError>>;
/// Send request, returns Response and Framed
fn open_tunnel(
@ -49,7 +49,7 @@ where
head: RequestHead,
body: Body,
addr: Option<net::SocketAddr>,
) -> Box<Future<Item = ClientResponse, Error = SendRequestError>> {
) -> Box<dyn Future<Item = ClientResponse, Error = SendRequestError>> {
Box::new(
self.0
// connect to the host

View File

@ -23,7 +23,7 @@ type HttpService = BoxedService<ServiceRequest, ServiceResponse, Error>;
type HttpNewService = BoxedNewService<(), ServiceRequest, ServiceResponse, Error, ()>;
type BoxedResponse = Either<
FutureResult<ServiceResponse, Error>,
Box<Future<Item = ServiceResponse, Error = Error>>,
Box<dyn Future<Item = ServiceResponse, Error = Error>>,
>;
type FnDataFactory = Box<Fn() -> Box<dyn Future<Item = Box<DataFactory>, Error = ()>>>;
@ -297,14 +297,14 @@ impl NewService for AppRoutingFactory {
}
}
type HttpServiceFut = Box<Future<Item = HttpService, Error = ()>>;
type HttpServiceFut = Box<dyn Future<Item = HttpService, Error = ()>>;
/// Create app service
#[doc(hidden)]
pub struct AppRoutingFactoryResponse {
fut: Vec<CreateAppRoutingItem>,
default: Option<HttpService>,
default_fut: Option<Box<Future<Item = HttpService, Error = ()>>>,
default_fut: Option<Box<dyn Future<Item = HttpService, Error = ()>>>,
}
enum CreateAppRoutingItem {

View File

@ -94,7 +94,7 @@ where
{
type Config = T::Config;
type Error = Error;
type Future = Box<Future<Item = Option<T>, Error = Error>>;
type Future = Box<dyn Future<Item = Option<T>, Error = Error>>;
#[inline]
fn from_request(req: &HttpRequest, payload: &mut Payload) -> Self::Future {
@ -165,7 +165,7 @@ where
{
type Config = T::Config;
type Error = Error;
type Future = Box<Future<Item = Result<T, T::Error>, Error = Error>>;
type Future = Box<dyn Future<Item = Result<T, T::Error>, Error = Error>>;
#[inline]
fn from_request(req: &HttpRequest, payload: &mut Payload) -> Self::Future {

View File

@ -119,7 +119,7 @@ where
type Request = ServiceRequest;
type Response = ServiceResponse<B>;
type Error = Error;
type Future = Box<Future<Item = Self::Response, Error = Self::Error>>;
type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error>>;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
self.service.poll_ready()

View File

@ -15,7 +15,7 @@ pub enum ErrorHandlerResponse<B> {
/// New http response got generated
Response(ServiceResponse<B>),
/// Result is a future that resolves to a new http response
Future(Box<Future<Item = ServiceResponse<B>, Error = Error>>),
Future(Box<dyn Future<Item = ServiceResponse<B>, Error = Error>>),
}
type ErrorHandler<B> = Fn(ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>>;
@ -117,7 +117,7 @@ where
type Request = ServiceRequest;
type Response = ServiceResponse<B>;
type Error = Error;
type Future = Box<Future<Item = Self::Response, Error = Self::Error>>;
type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error>>;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
self.service.poll_ready()

View File

@ -245,7 +245,7 @@ where
/// ```rust
/// # use actix_web::*;
/// # use futures::future::Future;
/// # fn index(req: HttpRequest) -> Box<Future<Item=HttpResponse, Error=Error>> {
/// # fn index(req: HttpRequest) -> Box<dyn Future<Item=HttpResponse, Error=Error>> {
/// # unimplemented!()
/// # }
/// App::new().service(web::resource("/").route(web::route().to_async(index)));
@ -478,7 +478,7 @@ pub struct CreateResourceService {
fut: Vec<CreateRouteServiceItem>,
data: Option<Rc<Extensions>>,
default: Option<HttpService>,
default_fut: Option<Box<Future<Item = HttpService, Error = ()>>>,
default_fut: Option<Box<dyn Future<Item = HttpService, Error = ()>>>,
}
impl Future for CreateResourceService {
@ -542,7 +542,7 @@ impl Service for ResourceService {
type Error = Error;
type Future = Either<
FutureResult<ServiceResponse, Error>,
Box<Future<Item = ServiceResponse, Error = Error>>,
Box<dyn Future<Item = ServiceResponse, Error = Error>>,
>;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {

View File

@ -337,7 +337,7 @@ impl<T: Responder> Future for CustomResponderFut<T> {
/// use actix_web::{Either, Error, HttpResponse};
///
/// type RegisterResult =
/// Either<HttpResponse, Box<Future<Item = HttpResponse, Error = Error>>>;
/// Either<HttpResponse, Box<dyn Future<Item = HttpResponse, Error = Error>>>;
///
/// fn index() -> RegisterResult {
/// if is_a_variant() {
@ -411,13 +411,13 @@ where
}
}
impl<I, E> Responder for Box<Future<Item = I, Error = E>>
impl<I, E> Responder for Box<dyn Future<Item = I, Error = E>>
where
I: Responder + 'static,
E: Into<Error> + 'static,
{
type Error = Error;
type Future = Box<Future<Item = Response, Error = Error>>;
type Future = Box<dyn Future<Item = Response, Error = Error>>;
#[inline]
fn respond_to(self, req: &HttpRequest) -> Self::Future {

View File

@ -19,7 +19,7 @@ type BoxedRouteService<Req, Res> = Box<
Error = Error,
Future = Either<
FutureResult<Res, Error>,
Box<Future<Item = Res, Error = Error>>,
Box<dyn Future<Item = Res, Error = Error>>,
>,
>,
>;
@ -32,7 +32,7 @@ type BoxedRouteNewService<Req, Res> = Box<
Error = Error,
InitError = (),
Service = BoxedRouteService<Req, Res>,
Future = Box<Future<Item = BoxedRouteService<Req, Res>, Error = ()>>,
Future = Box<dyn Future<Item = BoxedRouteService<Req, Res>, Error = ()>>,
>,
>;
@ -78,8 +78,9 @@ impl NewService for Route {
}
}
type RouteFuture =
Box<Future<Item = BoxedRouteService<ServiceRequest, ServiceResponse>, Error = ()>>;
type RouteFuture = Box<
dyn Future<Item = BoxedRouteService<ServiceRequest, ServiceResponse>, Error = ()>,
>;
pub struct CreateRouteService {
fut: RouteFuture,
@ -123,7 +124,7 @@ impl Service for RouteService {
type Error = Error;
type Future = Either<
FutureResult<Self::Response, Self::Error>,
Box<Future<Item = Self::Response, Error = Self::Error>>,
Box<dyn Future<Item = Self::Response, Error = Self::Error>>,
>;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
@ -317,7 +318,7 @@ where
type Error = Error;
type InitError = ();
type Service = BoxedRouteService<ServiceRequest, Self::Response>;
type Future = Box<Future<Item = Self::Service, Error = Self::InitError>>;
type Future = Box<dyn Future<Item = Self::Service, Error = Self::InitError>>;
fn new_service(&self, _: &()) -> Self::Future {
Box::new(
@ -351,7 +352,7 @@ where
type Error = Error;
type Future = Either<
FutureResult<Self::Response, Self::Error>,
Box<Future<Item = Self::Response, Error = Self::Error>>,
Box<dyn Future<Item = Self::Response, Error = Self::Error>>,
>;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {

View File

@ -28,7 +28,7 @@ type HttpService = BoxedService<ServiceRequest, ServiceResponse, Error>;
type HttpNewService = BoxedNewService<(), ServiceRequest, ServiceResponse, Error, ()>;
type BoxedResponse = Either<
FutureResult<ServiceResponse, Error>,
Box<Future<Item = ServiceResponse, Error = Error>>,
Box<dyn Future<Item = ServiceResponse, Error = Error>>,
>;
/// Resources scope.
@ -503,10 +503,10 @@ pub struct ScopeFactoryResponse {
fut: Vec<CreateScopeServiceItem>,
data: Option<Rc<Extensions>>,
default: Option<HttpService>,
default_fut: Option<Box<Future<Item = HttpService, Error = ()>>>,
default_fut: Option<Box<dyn Future<Item = HttpService, Error = ()>>>,
}
type HttpServiceFut = Box<Future<Item = HttpService, Error = ()>>;
type HttpServiceFut = Box<dyn Future<Item = HttpService, Error = ()>>;
enum CreateScopeServiceItem {
Future(Option<ResourceDef>, Option<Guards>, HttpServiceFut),

View File

@ -73,7 +73,7 @@ where
{
type Config = FormConfig;
type Error = Error;
type Future = Box<Future<Item = Self, Error = Error>>;
type Future = Box<dyn Future<Item = Self, Error = Error>>;
#[inline]
fn from_request(req: &HttpRequest, payload: &mut Payload) -> Self::Future {
@ -187,7 +187,7 @@ pub struct UrlEncoded<U> {
length: Option<usize>,
encoding: &'static Encoding,
err: Option<UrlencodedError>,
fut: Option<Box<Future<Item = U, Error = UrlencodedError>>>,
fut: Option<Box<dyn Future<Item = U, Error = UrlencodedError>>>,
}
impl<U> UrlEncoded<U> {

View File

@ -169,7 +169,7 @@ where
T: DeserializeOwned + 'static,
{
type Error = Error;
type Future = Box<Future<Item = Self, Error = Error>>;
type Future = Box<dyn Future<Item = Self, Error = Error>>;
type Config = JsonConfig;
#[inline]
@ -290,7 +290,7 @@ pub struct JsonBody<U> {
length: Option<usize>,
stream: Option<Decompress<Payload>>,
err: Option<JsonPayloadError>,
fut: Option<Box<Future<Item = U, Error = JsonPayloadError>>>,
fut: Option<Box<dyn Future<Item = U, Error = JsonPayloadError>>>,
}
impl<U> JsonBody<U>

View File

@ -124,7 +124,7 @@ impl FromRequest for Bytes {
type Config = PayloadConfig;
type Error = Error;
type Future =
Either<Box<Future<Item = Bytes, Error = Error>>, FutureResult<Bytes, Error>>;
Either<Box<dyn Future<Item = Bytes, Error = Error>>, FutureResult<Bytes, Error>>;
#[inline]
fn from_request(req: &HttpRequest, payload: &mut dev::Payload) -> Self::Future {
@ -177,8 +177,10 @@ impl FromRequest for Bytes {
impl FromRequest for String {
type Config = PayloadConfig;
type Error = Error;
type Future =
Either<Box<Future<Item = String, Error = Error>>, FutureResult<String, Error>>;
type Future = Either<
Box<dyn Future<Item = String, Error = Error>>,
FutureResult<String, Error>,
>;
#[inline]
fn from_request(req: &HttpRequest, payload: &mut dev::Payload) -> Self::Future {
@ -291,7 +293,7 @@ pub struct HttpMessageBody {
length: Option<usize>,
stream: Option<dev::Decompress<dev::Payload>>,
err: Option<PayloadError>,
fut: Option<Box<Future<Item = Bytes, Error = PayloadError>>>,
fut: Option<Box<dyn Future<Item = Bytes, Error = PayloadError>>>,
}
impl HttpMessageBody {