diff --git a/Cargo.toml b/Cargo.toml index 4d2d783ef..ce26e82e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,7 +84,9 @@ awc = { version = "2.0.0-alpha.1", default-features = false } bytes = "0.5.3" derive_more = "0.99.2" encoding_rs = "0.8" -futures = "0.3.1" +futures-channel = { version = "0.3.5", default-features = false } +futures-core = { version = "0.3.5", default-features = false } +futures-util = { version = "0.3.5", default-features = false } fxhash = "0.2.1" log = "0.4" mime = "0.3" diff --git a/benches/server.rs b/benches/server.rs index 93079a223..70531adf7 100644 --- a/benches/server.rs +++ b/benches/server.rs @@ -1,7 +1,7 @@ use actix_web::{test, web, App, HttpResponse}; use awc::Client; use criterion::{criterion_group, criterion_main, Criterion}; -use futures::future::join_all; +use futures_util::future::join_all; const STR: &str = "Hello World Hello World Hello World Hello World Hello World \ Hello World Hello World Hello World Hello World Hello World \ diff --git a/src/app.rs b/src/app.rs index 7d3100db7..9e38f5bc9 100644 --- a/src/app.rs +++ b/src/app.rs @@ -10,7 +10,7 @@ use actix_service::boxed::{self, BoxServiceFactory}; use actix_service::{ apply, apply_fn_factory, IntoServiceFactory, ServiceFactory, Transform, }; -use futures::future::FutureExt; +use futures_util::future::FutureExt; use crate::app_service::{AppEntry, AppInit, AppRoutingFactory}; use crate::config::ServiceConfig; @@ -474,7 +474,7 @@ where mod tests { use actix_service::Service; use bytes::Bytes; - use futures::future::{ok, err}; + use futures_util::future::{ok, err}; use super::*; use crate::http::{header, HeaderValue, Method, StatusCode}; diff --git a/src/app_service.rs b/src/app_service.rs index 693624ba0..233cfc0d5 100644 --- a/src/app_service.rs +++ b/src/app_service.rs @@ -9,7 +9,7 @@ use actix_http::{Extensions, Request, Response}; use actix_router::{Path, ResourceDef, ResourceInfo, Router, Url}; use actix_service::boxed::{self, BoxService, BoxServiceFactory}; use actix_service::{fn_service, Service, ServiceFactory}; -use futures::future::{join_all, ok, FutureExt, LocalBoxFuture}; +use futures_util::future::{join_all, ok, FutureExt, LocalBoxFuture}; use crate::config::{AppConfig, AppService}; use crate::data::{DataFactory, FnDataFactory}; diff --git a/src/data.rs b/src/data.rs index e657d8b7b..34ada863d 100644 --- a/src/data.rs +++ b/src/data.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use actix_http::error::{Error, ErrorInternalServerError}; use actix_http::Extensions; -use futures::future::{err, ok, LocalBoxFuture, Ready}; +use futures_util::future::{err, ok, LocalBoxFuture, Ready}; use crate::dev::Payload; use crate::extract::FromRequest; diff --git a/src/extract.rs b/src/extract.rs index 5289bd7db..df9c34cb3 100644 --- a/src/extract.rs +++ b/src/extract.rs @@ -4,7 +4,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; use actix_http::error::Error; -use futures::future::{ok, FutureExt, LocalBoxFuture, Ready}; +use futures_util::future::{ok, FutureExt, LocalBoxFuture, Ready}; use crate::dev::Payload; use crate::request::HttpRequest; @@ -50,7 +50,7 @@ pub trait FromRequest: Sized { /// ```rust /// use actix_web::{web, dev, App, Error, HttpRequest, FromRequest}; /// use actix_web::error::ErrorBadRequest; -/// use futures::future::{ok, err, Ready}; +/// use futures_util::future::{ok, err, Ready}; /// use serde_derive::Deserialize; /// use rand; /// @@ -122,7 +122,7 @@ where /// ```rust /// use actix_web::{web, dev, App, Result, Error, HttpRequest, FromRequest}; /// use actix_web::error::ErrorBadRequest; -/// use futures::future::{ok, err, Ready}; +/// use futures_util::future::{ok, err, Ready}; /// use serde_derive::Deserialize; /// use rand; /// diff --git a/src/handler.rs b/src/handler.rs index 33cd2408d..669512ab3 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -6,8 +6,8 @@ use std::task::{Context, Poll}; use actix_http::{Error, Response}; use actix_service::{Service, ServiceFactory}; -use futures::future::{ok, Ready}; -use futures::ready; +use futures_util::future::{ok, Ready}; +use futures_util::ready; use pin_project::pin_project; use crate::extract::FromRequest; diff --git a/src/middleware/compress.rs b/src/middleware/compress.rs index 70006ab3c..6de451c84 100644 --- a/src/middleware/compress.rs +++ b/src/middleware/compress.rs @@ -11,7 +11,7 @@ use actix_http::encoding::Encoder; use actix_http::http::header::{ContentEncoding, ACCEPT_ENCODING}; use actix_http::Error; use actix_service::{Service, Transform}; -use futures::future::{ok, Ready}; +use futures_util::future::{ok, Ready}; use pin_project::pin_project; use crate::dev::BodyEncoding; @@ -133,7 +133,7 @@ where fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); - match futures::ready!(this.fut.poll(cx)) { + match futures_util::ready!(this.fut.poll(cx)) { Ok(resp) => { let enc = if let Some(enc) = resp.response().get_encoding() { enc diff --git a/src/middleware/condition.rs b/src/middleware/condition.rs index 8c6909134..7ff81437b 100644 --- a/src/middleware/condition.rs +++ b/src/middleware/condition.rs @@ -2,7 +2,7 @@ use std::task::{Context, Poll}; use actix_service::{Service, Transform}; -use futures::future::{ok, Either, FutureExt, LocalBoxFuture}; +use futures_util::future::{ok, Either, FutureExt, LocalBoxFuture}; /// `Middleware` for conditionally enables another middleware. /// The controlled middleware must not change the `Service` interfaces. diff --git a/src/middleware/defaultheaders.rs b/src/middleware/defaultheaders.rs index ba001c77b..ef2e56e69 100644 --- a/src/middleware/defaultheaders.rs +++ b/src/middleware/defaultheaders.rs @@ -4,7 +4,7 @@ use std::rc::Rc; use std::task::{Context, Poll}; use actix_service::{Service, Transform}; -use futures::future::{ok, FutureExt, LocalBoxFuture, Ready}; +use futures_util::future::{ok, FutureExt, LocalBoxFuture, Ready}; use crate::http::header::{HeaderName, HeaderValue, CONTENT_TYPE}; use crate::http::{Error as HttpError, HeaderMap}; @@ -157,7 +157,7 @@ where #[cfg(test)] mod tests { use actix_service::IntoService; - use futures::future::ok; + use futures_util::future::ok; use super::*; use crate::dev::ServiceRequest; diff --git a/src/middleware/errhandlers.rs b/src/middleware/errhandlers.rs index 71886af0b..93a5d3f22 100644 --- a/src/middleware/errhandlers.rs +++ b/src/middleware/errhandlers.rs @@ -3,7 +3,7 @@ use std::rc::Rc; use std::task::{Context, Poll}; use actix_service::{Service, Transform}; -use futures::future::{ok, FutureExt, LocalBoxFuture, Ready}; +use futures_util::future::{ok, FutureExt, LocalBoxFuture, Ready}; use fxhash::FxHashMap; use crate::dev::{ServiceRequest, ServiceResponse}; @@ -147,7 +147,7 @@ where #[cfg(test)] mod tests { use actix_service::IntoService; - use futures::future::ok; + use futures_util::future::ok; use super::*; use crate::http::{header::CONTENT_TYPE, HeaderValue, StatusCode}; diff --git a/src/middleware/logger.rs b/src/middleware/logger.rs index d6b931bb4..e63efc832 100644 --- a/src/middleware/logger.rs +++ b/src/middleware/logger.rs @@ -11,7 +11,7 @@ use std::task::{Context, Poll}; use actix_service::{Service, Transform}; use bytes::Bytes; -use futures::future::{ok, Ready}; +use futures_util::future::{ok, Ready}; use log::debug; use regex::Regex; use time::OffsetDateTime; @@ -216,7 +216,7 @@ where fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); - let res = match futures::ready!(this.fut.poll(cx)) { + let res = match futures_util::ready!(this.fut.poll(cx)) { Ok(res) => res, Err(e) => return Poll::Ready(Err(e)), }; @@ -506,7 +506,7 @@ impl<'a> fmt::Display for FormatDisplay<'a> { #[cfg(test)] mod tests { use actix_service::{IntoService, Service, Transform}; - use futures::future::ok; + use futures_util::future::ok; use super::*; use crate::http::{header, StatusCode}; diff --git a/src/middleware/normalize.rs b/src/middleware/normalize.rs index 38b5310f7..139ec892e 100644 --- a/src/middleware/normalize.rs +++ b/src/middleware/normalize.rs @@ -4,7 +4,7 @@ use std::task::{Context, Poll}; use actix_http::http::{PathAndQuery, Uri}; use actix_service::{Service, Transform}; use bytes::Bytes; -use futures::future::{ok, Ready}; +use futures_util::future::{ok, Ready}; use regex::Regex; use crate::service::{ServiceRequest, ServiceResponse}; diff --git a/src/request.rs b/src/request.rs index 72fea1faf..f8abeb1bb 100644 --- a/src/request.rs +++ b/src/request.rs @@ -5,7 +5,7 @@ use std::{fmt, net}; use actix_http::http::{HeaderMap, Method, Uri, Version}; use actix_http::{Error, Extensions, HttpMessage, Message, Payload, RequestHead}; use actix_router::{Path, Url}; -use futures::future::{ok, Ready}; +use futures_util::future::{ok, Ready}; use tinyvec::TinyVec; use crate::config::AppConfig; diff --git a/src/resource.rs b/src/resource.rs index 4c0e26c18..5da1de62f 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -11,7 +11,7 @@ use actix_service::boxed::{self, BoxService, BoxServiceFactory}; use actix_service::{ apply, apply_fn_factory, IntoServiceFactory, Service, ServiceFactory, Transform, }; -use futures::future::{ok, Either, LocalBoxFuture, Ready}; +use futures_util::future::{ok, Either, LocalBoxFuture, Ready}; use crate::data::Data; use crate::dev::{insert_slash, AppService, HttpServiceFactory, ResourceDef}; @@ -588,7 +588,7 @@ mod tests { use actix_rt::time::delay_for; use actix_service::Service; - use futures::future::ok; + use futures_util::future::ok; use crate::http::{header, HeaderValue, Method, StatusCode}; use crate::middleware::DefaultHeaders; diff --git a/src/responder.rs b/src/responder.rs index 7189eecf1..367c9fccf 100644 --- a/src/responder.rs +++ b/src/responder.rs @@ -10,8 +10,8 @@ use actix_http::http::{ }; use actix_http::{Error, Response, ResponseBuilder}; use bytes::{Bytes, BytesMut}; -use futures::future::{err, ok, Either as EitherFuture, Ready}; -use futures::ready; +use futures_util::future::{err, ok, Either as EitherFuture, Ready}; +use futures_util::ready; use pin_project::{pin_project, project}; use crate::request::HttpRequest; diff --git a/src/route.rs b/src/route.rs index 11455630c..8da9aec1b 100644 --- a/src/route.rs +++ b/src/route.rs @@ -5,7 +5,7 @@ use std::task::{Context, Poll}; use actix_http::{http::Method, Error}; use actix_service::{Service, ServiceFactory}; -use futures::future::{ready, FutureExt, LocalBoxFuture}; +use futures_util::future::{ready, FutureExt, LocalBoxFuture}; use crate::extract::FromRequest; use crate::guard::{self, Guard}; diff --git a/src/scope.rs b/src/scope.rs index 5afca61da..b9166a4bf 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -1,5 +1,6 @@ use std::cell::RefCell; use std::fmt; +use std::future::Future; use std::pin::Pin; use std::rc::Rc; use std::task::{Context, Poll}; @@ -10,7 +11,7 @@ use actix_service::boxed::{self, BoxService, BoxServiceFactory}; use actix_service::{ apply, apply_fn_factory, IntoServiceFactory, Service, ServiceFactory, Transform, }; -use futures::future::{ok, Either, Future, LocalBoxFuture, Ready}; +use futures_util::future::{ok, Either, LocalBoxFuture, Ready}; use crate::config::ServiceConfig; use crate::data::Data; @@ -666,7 +667,7 @@ impl ServiceFactory for ScopeEndpoint { mod tests { use actix_service::Service; use bytes::Bytes; - use futures::future::ok; + use futures_util::future::ok; use crate::dev::{Body, ResponseBody}; use crate::http::{header, HeaderValue, Method, StatusCode}; diff --git a/src/server.rs b/src/server.rs index 97dd9f7f7..248cd39b3 100644 --- a/src/server.rs +++ b/src/server.rs @@ -13,7 +13,7 @@ use actix_http::Protocol; #[cfg(unix)] use actix_service::pipeline_factory; #[cfg(unix)] -use futures::future::ok; +use futures_util::future::ok; #[cfg(feature = "openssl")] use actix_tls::openssl::{AlpnError, SslAcceptor, SslAcceptorBuilder}; diff --git a/src/service.rs b/src/service.rs index c0148a9b2..232a2f132 100644 --- a/src/service.rs +++ b/src/service.rs @@ -536,7 +536,7 @@ mod tests { use crate::test::{init_service, TestRequest}; use crate::{guard, http, web, App, HttpResponse}; use actix_service::Service; - use futures::future::ok; + use futures_util::future::ok; #[test] fn test_service_request() { diff --git a/src/test.rs b/src/test.rs index c8a738d83..79e351eb3 100644 --- a/src/test.rs +++ b/src/test.rs @@ -18,8 +18,9 @@ use actix_service::{ use awc::error::PayloadError; use awc::{Client, ClientRequest, ClientResponse, Connector}; use bytes::{Bytes, BytesMut}; -use futures::future::ok; -use futures::stream::{Stream, StreamExt}; +use futures_core::Stream; +use futures_util::future::ok; +use futures_util::StreamExt; use net2::TcpBuilder; use serde::de::DeserializeOwned; use serde::Serialize; diff --git a/src/types/form.rs b/src/types/form.rs index d917345e1..ca1a4b103 100644 --- a/src/types/form.rs +++ b/src/types/form.rs @@ -9,8 +9,8 @@ use std::{fmt, ops}; use actix_http::{Error, HttpMessage, Payload, Response}; use bytes::BytesMut; use encoding_rs::{Encoding, UTF_8}; -use futures::future::{err, ok, FutureExt, LocalBoxFuture, Ready}; -use futures::StreamExt; +use futures_util::future::{err, ok, FutureExt, LocalBoxFuture, Ready}; +use futures_util::StreamExt; use serde::de::DeserializeOwned; use serde::Serialize; diff --git a/src/types/json.rs b/src/types/json.rs index df8aa4fc6..f746fd432 100644 --- a/src/types/json.rs +++ b/src/types/json.rs @@ -7,8 +7,8 @@ use std::task::{Context, Poll}; use std::{fmt, ops}; use bytes::BytesMut; -use futures::future::{err, ok, FutureExt, LocalBoxFuture, Ready}; -use futures::StreamExt; +use futures_util::future::{err, ok, FutureExt, LocalBoxFuture, Ready}; +use futures_util::StreamExt; use serde::de::DeserializeOwned; use serde::Serialize; diff --git a/src/types/path.rs b/src/types/path.rs index a37cb8f12..82050171c 100644 --- a/src/types/path.rs +++ b/src/types/path.rs @@ -4,7 +4,7 @@ use std::{fmt, ops}; use actix_http::error::{Error, ErrorNotFound}; use actix_router::PathDeserializer; -use futures::future::{ready, Ready}; +use futures_util::future::{ready, Ready}; use serde::de; use crate::dev::Payload; diff --git a/src/types/payload.rs b/src/types/payload.rs index 449e6c5b0..bad33bfc6 100644 --- a/src/types/payload.rs +++ b/src/types/payload.rs @@ -8,8 +8,9 @@ use actix_http::error::{Error, ErrorBadRequest, PayloadError}; use actix_http::HttpMessage; use bytes::{Bytes, BytesMut}; use encoding_rs::UTF_8; -use futures::future::{err, ok, Either, FutureExt, LocalBoxFuture, Ready}; -use futures::{Stream, StreamExt}; +use futures_core::stream::Stream; +use futures_util::future::{err, ok, Either, FutureExt, LocalBoxFuture, Ready}; +use futures_util::StreamExt; use mime::Mime; use crate::dev; @@ -22,9 +23,10 @@ use crate::request::HttpRequest; /// ## Example /// /// ```rust -/// use futures::{Future, Stream, StreamExt}; /// use actix_web::{web, error, App, Error, HttpResponse}; -/// +/// use std::future::Future; +/// use futures_core::stream::Stream; +/// use futures_util::StreamExt; /// /// extract binary data from request /// async fn index(mut body: web::Payload) -> Result /// { @@ -70,8 +72,10 @@ impl Stream for Payload { /// ## Example /// /// ```rust -/// use futures::{Future, Stream, StreamExt}; /// use actix_web::{web, error, App, Error, HttpResponse}; +/// use std::future::Future; +/// use futures_core::stream::Stream; +/// use futures_util::StreamExt; /// /// /// extract binary data from request /// async fn index(mut body: web::Payload) -> Result diff --git a/src/types/query.rs b/src/types/query.rs index 73ea14f17..cf1a8930d 100644 --- a/src/types/query.rs +++ b/src/types/query.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use std::{fmt, ops}; use actix_http::error::Error; -use futures::future::{err, ok, Ready}; +use futures_util::future::{err, ok, Ready}; use serde::de; use crate::dev::Payload; diff --git a/src/types/readlines.rs b/src/types/readlines.rs index 82853381b..f03235377 100644 --- a/src/types/readlines.rs +++ b/src/types/readlines.rs @@ -5,7 +5,7 @@ use std::task::{Context, Poll}; use bytes::{Bytes, BytesMut}; use encoding_rs::{Encoding, UTF_8}; -use futures::Stream; +use futures_util::stream::Stream; use crate::dev::Payload; use crate::error::{PayloadError, ReadlinesError}; @@ -172,7 +172,7 @@ where #[cfg(test)] mod tests { - use futures::stream::StreamExt; + use futures_util::stream::StreamExt; use super::*; use crate::test::TestRequest; diff --git a/src/web.rs b/src/web.rs index f47cf865e..1d1174f41 100644 --- a/src/web.rs +++ b/src/web.rs @@ -1,11 +1,11 @@ //! Essentials helper functions and types for application registration. use actix_http::http::Method; use actix_router::IntoPattern; -use futures::Future; +use std::future::Future; pub use actix_http::Response as HttpResponse; pub use bytes::{Bytes, BytesMut}; -pub use futures::channel::oneshot::Canceled; +pub use futures_channel::oneshot::Canceled; use crate::error::BlockingError; use crate::extract::FromRequest; diff --git a/tests/test_server.rs b/tests/test_server.rs index a4dfa65a0..926b211ee 100644 --- a/tests/test_server.rs +++ b/tests/test_server.rs @@ -1,3 +1,4 @@ +use std::future::Future; use std::io::{Read, Write}; use std::pin::Pin; use std::task::{Context, Poll}; @@ -11,7 +12,7 @@ use bytes::Bytes; use flate2::read::GzDecoder; use flate2::write::{GzEncoder, ZlibDecoder, ZlibEncoder}; use flate2::Compression; -use futures::{ready, Future}; +use futures_util::ready; use rand::{distributions::Alphanumeric, Rng}; use actix_web::dev::BodyEncoding; @@ -56,7 +57,7 @@ impl TestBody { } } -impl futures::Stream for TestBody { +impl futures_core::stream::Stream for TestBody { type Item = Result; fn poll_next(