Make futures-util dependency optional

This commit is contained in:
Benjamin Saunders
2021-12-19 14:07:38 -08:00
committed by Dirkjan Ochtman
parent 644ca88efd
commit 8d7d9451d0
3 changed files with 11 additions and 10 deletions
+3 -2
View File
@@ -14,7 +14,7 @@ edition = "2018"
all-features = true
[features]
default = ["native-certs", "tls-rustls", "ring"]
default = ["native-certs", "tls-rustls", "ring", "futures-util"]
# Records how long locks are held, and warns if they are held >= 1ms
lock_tracking = []
# Provides `ClientConfig::with_native_roots()` convenience method
@@ -29,7 +29,8 @@ maintenance = { status = "experimental" }
[dependencies]
bytes = "1"
futures-util = { version = "0.3.11", default-features = false, features = ["io"] }
# Enables futures_util::io::{AsyncRead, AsyncWrite} support for streams
futures-util = { version = "0.3.11", default-features = false, features = ["io"], optional = true }
futures-core = "0.3.19"
futures-channel = "0.3.11"
rustc-hash = "1.1"
+2 -2
View File
@@ -6,7 +6,6 @@ use std::{
};
use bytes::Bytes;
use futures_util::io::AsyncRead;
use proto::{Chunk, Chunks, ConnectionError, ReadableError, StreamId};
use thiserror::Error;
use tokio::io::ReadBuf;
@@ -355,7 +354,8 @@ pub enum ReadToEndError {
TooLong,
}
impl AsyncRead for RecvStream {
#[cfg(feature = "futures-util")]
impl futures_util::io::AsyncRead for RecvStream {
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context,
+6 -6
View File
@@ -7,7 +7,6 @@ use std::{
use bytes::Bytes;
use futures_channel::oneshot;
use futures_util::io::AsyncWrite;
use proto::{ConnectionError, FinishError, StreamId, Written};
use thiserror::Error;
@@ -220,9 +219,10 @@ impl SendStream {
}
}
impl AsyncWrite for SendStream {
#[cfg(feature = "futures-util")]
impl futures_util::io::AsyncWrite for SendStream {
fn poll_write(self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll<io::Result<usize>> {
SendStream::execute_poll(self.get_mut(), cx, |stream| stream.write(buf)).map_err(Into::into)
tokio::io::AsyncWrite::poll_write(self, cx, buf)
}
fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<io::Result<()>> {
@@ -230,7 +230,7 @@ impl AsyncWrite for SendStream {
}
fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
self.get_mut().poll_finish(cx).map_err(Into::into)
tokio::io::AsyncWrite::poll_shutdown(self, cx)
}
}
@@ -240,7 +240,7 @@ impl tokio::io::AsyncWrite for SendStream {
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<io::Result<usize>> {
AsyncWrite::poll_write(self, cx, buf)
SendStream::execute_poll(self.get_mut(), cx, |stream| stream.write(buf)).map_err(Into::into)
}
fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<io::Result<()>> {
@@ -248,7 +248,7 @@ impl tokio::io::AsyncWrite for SendStream {
}
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
AsyncWrite::poll_close(self, cx)
self.get_mut().poll_finish(cx).map_err(Into::into)
}
}