Skip to content

Commit

Permalink
Replace futures with futures-util (#906)
Browse files Browse the repository at this point in the history
* Replace `futures` with `futures-util`

* Add `sink` feature for `futures-util`
  • Loading branch information
nylonicious authored Oct 10, 2021
1 parent 9e74ff9 commit 25eedf6
Show file tree
Hide file tree
Showing 43 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ all-features = true
[dependencies]
async-compression = { version = "0.3.7", features = ["brotli", "deflate", "gzip", "tokio"], optional = true }
bytes = "1.0"
futures = { version = "0.3", default-features = false, features = ["alloc"] }
futures-util = { version = "0.3", default-features = false, features = ["sink"] }
headers = "0.3"
http = "0.2"
hyper = { version = "0.14", features = ["stream", "server", "http1", "tcp", "client"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/sse.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futures::StreamExt;
use futures_util::StreamExt;
use std::convert::Infallible;
use std::time::Duration;
use tokio::time::interval;
Expand Down
2 changes: 1 addition & 1 deletion examples/sse_chat.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futures::{Stream, StreamExt};
use futures_util::{Stream, StreamExt};
use std::collections::HashMap;
use std::sync::{
atomic::{AtomicUsize, Ordering},
Expand Down
2 changes: 1 addition & 1 deletion examples/websockets.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![deny(warnings)]

use futures::{FutureExt, StreamExt};
use futures_util::{FutureExt, StreamExt};
use warp::Filter;

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion examples/websockets_chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::{
Arc,
};

use futures::{SinkExt, StreamExt, TryFutureExt};
use futures_util::{SinkExt, StreamExt, TryFutureExt};
use tokio::sync::{mpsc, RwLock};
use tokio_stream::wrappers::UnboundedReceiverStream;
use warp::ws::{Message, WebSocket};
Expand Down
2 changes: 1 addition & 1 deletion src/filter/and.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

use futures::ready;
use futures_util::ready;
use pin_project::pin_project;

use super::{Combine, Filter, FilterBase, Internal, Tuple};
Expand Down
2 changes: 1 addition & 1 deletion src/filter/and_then.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

use futures::{ready, TryFuture};
use futures_util::{ready, TryFuture};
use pin_project::pin_project;

use super::{Filter, FilterBase, Func, Internal};
Expand Down
2 changes: 1 addition & 1 deletion src/filter/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;

use futures::TryFutureExt;
use futures_util::TryFutureExt;

use super::{Filter, FilterBase, Internal, Tuple};
use crate::reject::Rejection;
Expand Down
2 changes: 1 addition & 1 deletion src/filter/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

use futures::{ready, TryFuture};
use futures_util::{ready, TryFuture};
use pin_project::pin_project;

use super::{Filter, FilterBase, Func, Internal};
Expand Down
2 changes: 1 addition & 1 deletion src/filter/map_err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

use futures::TryFuture;
use futures_util::TryFuture;
use pin_project::pin_project;

use super::{Filter, FilterBase, Internal};
Expand Down
2 changes: 1 addition & 1 deletion src/filter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mod wrap;

use std::future::Future;

use futures::{future, TryFuture, TryFutureExt};
use futures_util::{future, TryFuture, TryFutureExt};

pub(crate) use crate::generic::{one, Combine, Either, Func, One, Tuple};
use crate::reject::{CombineRejection, IsReject, Rejection};
Expand Down
2 changes: 1 addition & 1 deletion src/filter/or.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

use futures::{ready, TryFuture};
use futures_util::{ready, TryFuture};
use pin_project::pin_project;

use super::{Filter, FilterBase, Internal};
Expand Down
2 changes: 1 addition & 1 deletion src/filter/or_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

use futures::{ready, TryFuture};
use futures_util::{ready, TryFuture};
use pin_project::pin_project;

use super::{Filter, FilterBase, Func, Internal};
Expand Down
2 changes: 1 addition & 1 deletion src/filter/recover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

use futures::{ready, TryFuture};
use futures_util::{ready, TryFuture};
use pin_project::pin_project;

use super::{Filter, FilterBase, Func, Internal};
Expand Down
2 changes: 1 addition & 1 deletion src/filter/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::net::SocketAddr;
use std::pin::Pin;
use std::task::{Context, Poll};

use futures::future::TryFuture;
use futures_util::future::TryFuture;
use hyper::service::Service;
use pin_project::pin_project;

Expand Down
2 changes: 1 addition & 1 deletion src/filter/then.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

use futures::{ready, TryFuture};
use futures_util::{ready, TryFuture};
use pin_project::pin_project;

use super::{Filter, FilterBase, Func, Internal};
Expand Down
2 changes: 1 addition & 1 deletion src/filter/unify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

use futures::{ready, TryFuture};
use futures_util::{ready, TryFuture};
use pin_project::pin_project;

use super::{Either, Filter, FilterBase, Internal, Tuple};
Expand Down
2 changes: 1 addition & 1 deletion src/filter/untuple_one.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

use futures::{ready, TryFuture};
use futures_util::{ready, TryFuture};
use pin_project::pin_project;

use super::{Filter, FilterBase, Internal, Tuple};
Expand Down
2 changes: 1 addition & 1 deletion src/filters/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ use crate::filter::{filter_fn_one, Filter};
/// });
/// ```
pub fn remote() -> impl Filter<Extract = (Option<SocketAddr>,), Error = Infallible> + Copy {
filter_fn_one(|route| futures::future::ok(route.remote_addr()))
filter_fn_one(|route| futures_util::future::ok(route.remote_addr()))
}
2 changes: 1 addition & 1 deletion src/filters/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::pin::Pin;
use std::task::{Context, Poll};

use bytes::{Buf, Bytes};
use futures::{future, ready, Stream, TryFutureExt};
use futures_util::{future, ready, Stream, TryFutureExt};
use headers::ContentLength;
use http::header::CONTENT_TYPE;
use hyper::Body;
Expand Down
2 changes: 1 addition & 1 deletion src/filters/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ mod internal {
use std::task::{Context, Poll};

use bytes::Bytes;
use futures::{ready, Stream, TryFuture};
use futures_util::{ready, Stream, TryFuture};
use hyper::Body;
use pin_project::pin_project;

Expand Down
2 changes: 1 addition & 1 deletion src/filters/cookie.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Cookie Filters

use futures::future;
use futures_util::future;
use headers::Cookie;

use super::header;
Expand Down
2 changes: 1 addition & 1 deletion src/filters/cors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ mod internal {
use std::sync::Arc;
use std::task::{Context, Poll};

use futures::{future, ready, TryFuture};
use futures_util::{future, ready, TryFuture};
use headers::Origin;
use http::header;
use pin_project::pin_project;
Expand Down
2 changes: 1 addition & 1 deletion src/filters/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::convert::Infallible;

use futures::future;
use futures_util::future;

use crate::filter::{filter_fn_one, Filter};
use crate::reject::{self, Rejection};
Expand Down
4 changes: 2 additions & 2 deletions src/filters/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use std::sync::Arc;
use std::task::Poll;

use bytes::{Bytes, BytesMut};
use futures::future::Either;
use futures::{future, ready, stream, FutureExt, Stream, StreamExt, TryFutureExt};
use futures_util::future::Either;
use futures_util::{future, ready, stream, FutureExt, Stream, StreamExt, TryFutureExt};
use headers::{
AcceptRanges, ContentLength, ContentRange, ContentType, HeaderMapExt, IfModifiedSince, IfRange,
IfUnmodifiedSince, LastModified, Range,
Expand Down
2 changes: 1 addition & 1 deletion src/filters/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use std::convert::Infallible;
use std::str::FromStr;

use futures::future;
use futures_util::future;
use headers::{Header, HeaderMapExt};
use http::header::HeaderValue;
use http::HeaderMap;
Expand Down
2 changes: 1 addition & 1 deletion src/filters/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
use crate::filter::{filter_fn_one, Filter, One};
use crate::reject::{self, Rejection};
use futures::future;
use futures_util::future;
pub use http::uri::Authority;
use std::str::FromStr;

Expand Down
2 changes: 1 addition & 1 deletion src/filters/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ mod internal {
use std::task::{Context, Poll};
use std::time::Instant;

use futures::{ready, TryFuture};
use futures_util::{ready, TryFuture};
use pin_project::pin_project;

use super::{Info, Log};
Expand Down
2 changes: 1 addition & 1 deletion src/filters/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//!
//! There is also [`warp::method()`](method), which never rejects
//! a request, and just extracts the method to be used in your filter chains.
use futures::future;
use futures_util::future;
use http::Method;

use crate::filter::{filter_fn, filter_fn_one, Filter, One};
Expand Down
2 changes: 1 addition & 1 deletion src/filters/multipart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::pin::Pin;
use std::task::{Context, Poll};

use bytes::{Buf, Bytes};
use futures::{future, Stream};
use futures_util::{future, Stream};
use headers::ContentType;
use mime::Mime;
use multipart::server::Multipart;
Expand Down
2 changes: 1 addition & 1 deletion src/filters/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ use std::convert::Infallible;
use std::fmt;
use std::str::FromStr;

use futures::future;
use futures_util::future;
use http::uri::PathAndQuery;

use self::internal::Opaque;
Expand Down
2 changes: 1 addition & 1 deletion src/filters/query.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Query Filters

use futures::future;
use futures_util::future;
use serde::de::DeserializeOwned;
use serde_urlencoded;

Expand Down
10 changes: 5 additions & 5 deletions src/filters/sse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! use std::time::Duration;
//! use std::convert::Infallible;
//! use warp::{Filter, sse::Event};
//! use futures::{stream::iter, Stream};
//! use futures_util::{stream::iter, Stream};
//!
//! fn sse_events() -> impl Stream<Item = Result<Event, Infallible>> {
//! iter(vec![
Expand Down Expand Up @@ -49,7 +49,7 @@ use std::str::FromStr;
use std::task::{Context, Poll};
use std::time::Duration;

use futures::{future, Stream, TryStream, TryStreamExt};
use futures_util::{future, Stream, TryStream, TryStreamExt};
use http::header::{HeaderValue, CACHE_CONTROL, CONTENT_TYPE};
use hyper::Body;
use pin_project::pin_project;
Expand Down Expand Up @@ -244,8 +244,8 @@ where
/// ```
///
/// use std::time::Duration;
/// use futures::Stream;
/// use futures::stream::iter;
/// use futures_util::Stream;
/// use futures_util::stream::iter;
/// use std::convert::Infallible;
/// use warp::{Filter, sse::Event};
/// use serde_derive::Serialize;
Expand Down Expand Up @@ -419,7 +419,7 @@ struct SseKeepAlive<S> {
/// ```
/// use std::time::Duration;
/// use std::convert::Infallible;
/// use futures::StreamExt;
/// use futures_util::StreamExt;
/// use tokio::time::interval;
/// use tokio_stream::wrappers::IntervalStream;
/// use warp::{Filter, Stream, sse::Event};
Expand Down
2 changes: 1 addition & 1 deletion src/filters/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl<'a> Info<'a> {
}

mod internal {
use futures::{future::Inspect, future::MapOk, FutureExt, TryFutureExt};
use futures_util::{future::Inspect, future::MapOk, FutureExt, TryFutureExt};

use super::{Info, Trace};
use crate::filter::{Filter, FilterBase, Internal};
Expand Down
2 changes: 1 addition & 1 deletion src/filters/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use super::header;
use crate::filter::{filter_fn_one, Filter, One};
use crate::reject::Rejection;
use crate::reply::{Reply, Response};
use futures::{future, ready, FutureExt, Sink, Stream, TryFutureExt};
use futures_util::{future, ready, FutureExt, Sink, Stream, TryFutureExt};
use headers::{Connection, HeaderMapExt, SecWebsocketAccept, SecWebsocketKey, Upgrade};
use http;
use hyper::upgrade::OnUpgrade;
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub use hyper;
#[doc(hidden)]
pub use bytes::Buf;
#[doc(hidden)]
pub use futures::{Future, Sink, Stream};
pub use futures_util::{Future, Sink, Stream};
#[doc(hidden)]

pub(crate) type Request = http::Request<hyper::Body>;
4 changes: 2 additions & 2 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::net::SocketAddr;
#[cfg(feature = "tls")]
use std::path::Path;

use futures::{future, FutureExt, TryFuture, TryStream, TryStreamExt};
use futures_util::{future, FutureExt, TryFuture, TryStream, TryStreamExt};
use hyper::server::conn::AddrIncoming;
use hyper::service::{make_service_fn, service_fn};
use hyper::Server as HyperServer;
Expand Down Expand Up @@ -254,7 +254,7 @@ where
///
/// ```no_run
/// use warp::Filter;
/// use futures::future::TryFutureExt;
/// use futures_util::future::TryFutureExt;
/// use tokio::sync::oneshot;
///
/// # fn main() {
Expand Down
6 changes: 3 additions & 3 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ use std::task::{self, Poll};

use bytes::Bytes;
#[cfg(feature = "websocket")]
use futures::StreamExt;
use futures::{future, FutureExt, TryFutureExt};
use futures_util::StreamExt;
use futures_util::{future, FutureExt, TryFutureExt};
use http::{
header::{HeaderName, HeaderValue},
Response,
Expand Down Expand Up @@ -460,7 +460,7 @@ impl WsBuilder {
/// # Example
///
/// ```no_run
/// use futures::future;
/// use futures_util::future;
/// use warp::Filter;
/// #[tokio::main]
/// # async fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::sync::Arc;
use std::task::{Context, Poll};
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};

use futures::ready;
use futures_util::ready;
use hyper::server::accept::Accept;
use hyper::server::conn::{AddrIncoming, AddrStream};

Expand Down
2 changes: 1 addition & 1 deletion tests/body.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![deny(warnings)]

use bytes::Buf;
use futures::TryStreamExt;
use futures_util::TryStreamExt;
use warp::Filter;

#[tokio::test]
Expand Down
Loading

0 comments on commit 25eedf6

Please sign in to comment.