Skip to content

Commit acf23c5

Browse files
chore(deps): replace futures with futures-util (#281)
1 parent 5a9e80e commit acf23c5

File tree

11 files changed

+25
-27
lines changed

11 files changed

+25
-27
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ hyper-rustls = { version = "0.27.3", default-features = false, features = [
137137
"tls12",
138138
], optional = true }
139139
url = "2.1.1"
140-
futures = "0.3.5"
141-
futures-channel = "0.3.30"
140+
futures-util = { version = "0.3.5", default-features = false, features = ["sink", "io"] }
141+
futures-channel = { version = "0.3.30", features = ["sink"] }
142142
static_assertions = "1.1"
143143
sealed = "0.6"
144144
lz4_flex = { version = "0.11.3", default-features = false, features = [

benches/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::{
1212

1313
use bytes::Bytes;
1414
use clickhouse::error::Result;
15-
use futures::stream::StreamExt;
15+
use futures_util::stream::StreamExt;
1616
use http_body_util::BodyExt;
1717
use hyper::{
1818
body::{Body, Incoming},

benches/mocked_select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clickhouse::{
55
};
66
use clickhouse_types::{Column, DataTypeNode};
77
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
8-
use futures::stream::{self, StreamExt as _};
8+
use futures_util::stream::{self, StreamExt as _};
99
use http_body_util::StreamBody;
1010
use hyper::{
1111
body::{Body, Frame, Incoming},

examples/stream_into_file.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ async fn cursor_next(filename: &str) {
4545
}
4646
}
4747

48-
// Pattern 3: use the `futures::(Try)StreamExt` traits.
48+
// Pattern 3: use the `futures_util::(Try)StreamExt` traits.
4949
#[cfg(feature = "futures03")]
5050
async fn futures03_stream(filename: &str) {
51-
use futures::TryStreamExt;
51+
use futures_util::TryStreamExt;
5252

5353
let mut cursor = query(NUMBERS);
5454
let mut file = File::create(filename).await.unwrap();

src/compression/lz4.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std::{
22
pin::Pin,
3-
task::{Context, Poll},
3+
task::{ready, Context, Poll},
44
};
55

66
use bytes::{Buf, BufMut, Bytes, BytesMut};
77
use cityhash_rs::cityhash_102_128;
8-
use futures::{ready, stream::Stream};
8+
use futures_util::stream::Stream;
99
use lz4_flex::block;
1010

1111
use crate::{
@@ -182,7 +182,7 @@ pub(crate) fn compress(uncompressed: &[u8]) -> Result<Bytes> {
182182

183183
#[tokio::test]
184184
async fn it_decompresses() {
185-
use futures::stream::{self, TryStreamExt};
185+
use futures_util::stream::{self, TryStreamExt};
186186

187187
let expected = vec![
188188
1u8, 0, 2, 255, 255, 255, 255, 0, 1, 1, 1, 115, 6, 83, 116, 114, 105, 110, 103, 3, 97, 98,

src/cursors/bytes.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ use tokio::io::{AsyncBufRead, AsyncRead, ReadBuf};
1717
/// Additionally to [`BytesCursor::next`] and [`BytesCursor::collect`],
1818
/// this cursor implements:
1919
/// * [`AsyncRead`] and [`AsyncBufRead`] for `tokio`-based ecosystem.
20-
/// * [`futures::Stream`], [`futures::AsyncRead`] and [`futures::AsyncBufRead`]
21-
/// for `futures`-based ecosystem. (requires the `futures03` feature)
20+
/// * [`futures_util::Stream`], [`futures_util::AsyncRead`] and
21+
/// [`futures_util::AsyncBufRead`] for `futures`-based ecosystem.
22+
/// (requires the `futures03` feature)
2223
///
2324
/// For instance, if the requested format emits each row on a newline
2425
/// (e.g. `JSONEachRow`, `CSV`, `TSV`, etc.), the cursor can be read line by
@@ -167,7 +168,7 @@ impl AsyncBufRead for BytesCursor {
167168
}
168169

169170
#[cfg(feature = "futures03")]
170-
impl futures::AsyncRead for BytesCursor {
171+
impl futures_util::AsyncRead for BytesCursor {
171172
#[inline]
172173
fn poll_read(
173174
self: Pin<&mut Self>,
@@ -181,7 +182,7 @@ impl futures::AsyncRead for BytesCursor {
181182
}
182183

183184
#[cfg(feature = "futures03")]
184-
impl futures::AsyncBufRead for BytesCursor {
185+
impl futures_util::AsyncBufRead for BytesCursor {
185186
#[inline]
186187
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<IoResult<&[u8]>> {
187188
AsyncBufRead::poll_fill_buf(self, cx)
@@ -194,7 +195,7 @@ impl futures::AsyncBufRead for BytesCursor {
194195
}
195196

196197
#[cfg(feature = "futures03")]
197-
impl futures::stream::Stream for BytesCursor {
198+
impl futures_util::stream::Stream for BytesCursor {
198199
type Item = crate::error::Result<bytes::Bytes>;
199200

200201
#[inline]
@@ -209,7 +210,7 @@ impl futures::stream::Stream for BytesCursor {
209210
}
210211

211212
#[cfg(feature = "futures03")]
212-
impl futures::stream::FusedStream for BytesCursor {
213+
impl futures_util::stream::FusedStream for BytesCursor {
213214
#[inline]
214215
fn is_terminated(&self) -> bool {
215216
self.bytes.is_empty() && self.raw.is_terminated()

src/cursors/raw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
response::{Chunks, Response, ResponseFuture},
44
};
55
use bytes::Bytes;
6-
use futures::Stream;
6+
use futures_util::Stream;
77
use std::{
88
pin::pin,
99
task::{ready, Context, Poll},

src/request_body.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use std::{
66
};
77

88
use bytes::Bytes;
9-
use futures::{SinkExt, Stream};
109
use futures_channel::mpsc;
10+
use futures_util::{SinkExt, Stream};
1111
use hyper::body::{Body, Frame, SizeHint};
1212

1313
// === RequestBody ===

src/response.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
use std::{
2-
future::Future,
3-
pin::Pin,
2+
future::{self, Future},
3+
pin::{pin, Pin},
44
task::{Context, Poll},
55
};
66

77
use bstr::ByteSlice;
88
use bytes::{BufMut, Bytes};
9-
use futures::{
10-
future,
11-
stream::{self, Stream, TryStreamExt},
12-
};
9+
use futures_util::stream::{self, Stream, TryStreamExt};
1310
use http_body_util::BodyExt as _;
1411
use hyper::{
1512
body::{Body as _, Incoming},
@@ -125,7 +122,7 @@ async fn collect_bad_response(
125122
}
126123

127124
async fn collect_bytes(stream: impl Stream<Item = Result<Bytes>>) -> Result<Bytes> {
128-
futures::pin_mut!(stream);
125+
let mut stream = pin!(stream);
129126

130127
let mut bytes = Vec::new();
131128

src/test/handlers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::marker::PhantomData;
22

33
use bytes::Bytes;
4-
use futures::channel::oneshot;
4+
use futures_channel::oneshot;
55
use hyper::{Request, Response, StatusCode};
66
use sealed::sealed;
77
use serde::Serialize;

0 commit comments

Comments
 (0)