Skip to content

Commit 8f955eb

Browse files
authored
Merge pull request #935 from Some-Dood/deps/prefer-sub-crates
Deps: prefer sub-crates of `futures`
2 parents a624282 + 44eac98 commit 8f955eb

31 files changed

+57
-55
lines changed

postgres-native-tls/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ default = ["runtime"]
1616
runtime = ["tokio-postgres/runtime"]
1717

1818
[dependencies]
19-
futures = "0.3"
2019
native-tls = "0.2"
2120
tokio = "1.0"
2221
tokio-native-tls = "0.3"
2322
tokio-postgres = { version = "0.7.0", path = "../tokio-postgres", default-features = false }
2423

2524
[dev-dependencies]
26-
tokio = { version = "1.0", features = ["full"] }
25+
futures-util = "0.3"
26+
tokio = { version = "1.0", features = ["macros", "net", "rt"] }
2727
postgres = { version = "0.19.0", path = "../postgres" }

postgres-native-tls/src/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use futures::FutureExt;
1+
use futures_util::FutureExt;
22
use native_tls::{self, Certificate};
33
use tokio::net::TcpStream;
44
use tokio_postgres::tls::TlsConnect;

postgres-openssl/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ default = ["runtime"]
1616
runtime = ["tokio-postgres/runtime"]
1717

1818
[dependencies]
19-
futures = "0.3"
2019
openssl = "0.10"
2120
tokio = "1.0"
2221
tokio-openssl = "0.6"
2322
tokio-postgres = { version = "0.7.0", path = "../tokio-postgres", default-features = false }
2423

2524
[dev-dependencies]
26-
tokio = { version = "1.0", features = ["full"] }
25+
futures-util = "0.3"
26+
tokio = { version = "1.0", features = ["macros", "net", "rt"] }
2727
postgres = { version = "0.19.0", path = "../postgres" }

postgres-openssl/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,17 @@ use tokio_postgres::tls::{ChannelBinding, TlsConnect};
7373
#[cfg(test)]
7474
mod test;
7575

76+
type ConfigCallback =
77+
dyn Fn(&mut ConnectConfiguration, &str) -> Result<(), ErrorStack> + Sync + Send;
78+
7679
/// A `MakeTlsConnect` implementation using the `openssl` crate.
7780
///
7881
/// Requires the `runtime` Cargo feature (enabled by default).
7982
#[cfg(feature = "runtime")]
8083
#[derive(Clone)]
8184
pub struct MakeTlsConnector {
8285
connector: SslConnector,
83-
config: Arc<dyn Fn(&mut ConnectConfiguration, &str) -> Result<(), ErrorStack> + Sync + Send>,
86+
config: Arc<ConfigCallback>,
8487
}
8588

8689
#[cfg(feature = "runtime")]

postgres-openssl/src/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use futures::FutureExt;
1+
use futures_util::FutureExt;
22
use openssl::ssl::{SslConnector, SslMethod};
33
use tokio::net::TcpStream;
44
use tokio_postgres::tls::TlsConnect;

postgres-types/src/special.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{i32, i64};
66
use crate::{FromSql, IsNull, ToSql, Type};
77

88
/// A wrapper that can be used to represent infinity with `Type::Date` types.
9-
#[derive(Debug, Clone, Copy, PartialEq)]
9+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1010
pub enum Date<T> {
1111
/// Represents `infinity`, a date that is later than all other dates.
1212
PosInfinity,
@@ -55,7 +55,7 @@ impl<T: ToSql> ToSql for Date<T> {
5555

5656
/// A wrapper that can be used to represent infinity with `Type::Timestamp` and `Type::Timestamptz`
5757
/// types.
58-
#[derive(Debug, Clone, Copy, PartialEq)]
58+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5959
pub enum Timestamp<T> {
6060
/// Represents `infinity`, a timestamp that is later than all other timestamps.
6161
PosInfinity,

postgres/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ with-time-0_3 = ["tokio-postgres/with-time-0_3"]
3737
[dependencies]
3838
bytes = "1.0"
3939
fallible-iterator = "0.2"
40-
futures = "0.3"
40+
futures-util = { version = "0.3", features = ["sink"] }
4141
tokio-postgres = { version = "0.7.6", path = "../tokio-postgres" }
4242

4343
tokio = { version = "1.0", features = ["rt", "time"] }
4444
log = "0.4"
4545

4646
[dev-dependencies]
4747
criterion = "0.3"
48+
tokio = { version = "1.0", features = ["rt-multi-thread"] }

postgres/src/binary_copy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::connection::ConnectionRef;
44
use crate::types::{BorrowToSql, ToSql, Type};
55
use crate::{CopyInWriter, CopyOutReader, Error};
66
use fallible_iterator::FallibleIterator;
7-
use futures::StreamExt;
7+
use futures_util::StreamExt;
88
use std::pin::Pin;
99
#[doc(inline)]
1010
pub use tokio_postgres::binary_copy::BinaryCopyOutRow;

postgres/src/connection.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::{Error, Notification};
2-
use futures::future;
3-
use futures::{pin_mut, Stream};
2+
use futures_util::{future, pin_mut, Stream};
43
use std::collections::VecDeque;
54
use std::future::Future;
65
use std::ops::{Deref, DerefMut};

postgres/src/copy_in_writer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::connection::ConnectionRef;
22
use crate::lazy_pin::LazyPin;
33
use bytes::{Bytes, BytesMut};
4-
use futures::SinkExt;
4+
use futures_util::SinkExt;
55
use std::io;
66
use std::io::Write;
77
use tokio_postgres::{CopyInSink, Error};

postgres/src/copy_out_reader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::connection::ConnectionRef;
22
use crate::lazy_pin::LazyPin;
33
use bytes::{Buf, Bytes};
4-
use futures::StreamExt;
4+
use futures_util::StreamExt;
55
use std::io::{self, BufRead, Read};
66
use tokio_postgres::CopyOutStream;
77

postgres/src/notifications.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::connection::ConnectionRef;
44
use crate::{Error, Notification};
55
use fallible_iterator::FallibleIterator;
6-
use futures::{ready, FutureExt};
6+
use futures_util::{ready, FutureExt};
77
use std::pin::Pin;
88
use std::task::Poll;
99
use std::time::Duration;

postgres/src/row_iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::connection::ConnectionRef;
22
use fallible_iterator::FallibleIterator;
3-
use futures::StreamExt;
3+
use futures_util::StreamExt;
44
use std::pin::Pin;
55
use tokio_postgres::{Error, Row, RowStream};
66

tokio-postgres/Cargo.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ async-trait = "0.1"
4545
bytes = "1.0"
4646
byteorder = "1.0"
4747
fallible-iterator = "0.2"
48-
futures = "0.3"
48+
futures-channel = { version = "0.3", features = ["sink"] }
49+
futures-util = { version = "0.3", features = ["sink"] }
4950
log = "0.4"
5051
parking_lot = "0.12"
5152
percent-encoding = "2.0"
@@ -58,9 +59,10 @@ tokio = { version = "1.0", features = ["io-util"] }
5859
tokio-util = { version = "0.7", features = ["codec"] }
5960

6061
[dev-dependencies]
61-
tokio = { version = "1.0", features = ["full"] }
62-
env_logger = "0.9"
62+
futures-executor = "0.3"
6363
criterion = "0.3"
64+
env_logger = "0.9"
65+
tokio = { version = "1.0", features = ["macros", "net", "rt", "rt-multi-thread", "time"] }
6466

6567
bit-vec-06 = { version = "0.6", package = "bit-vec" }
6668
chrono-04 = { version = "0.4", package = "chrono", default-features = false }

tokio-postgres/benches/bench.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use criterion::{criterion_group, criterion_main, Criterion};
2-
use futures::channel::oneshot;
3-
use futures::executor;
2+
use futures_channel::oneshot;
43
use std::sync::Arc;
54
use std::time::Instant;
65
use tokio::runtime::Runtime;
@@ -32,7 +31,7 @@ fn query_prepared(c: &mut Criterion) {
3231
let (client, runtime) = setup();
3332
let statement = runtime.block_on(client.prepare("SELECT $1::INT8")).unwrap();
3433
c.bench_function("executor_block_on", move |b| {
35-
b.iter(|| executor::block_on(client.query(&statement, &[&1i64])).unwrap())
34+
b.iter(|| futures_executor::block_on(client.query(&statement, &[&1i64])).unwrap())
3635
});
3736

3837
let (client, runtime) = setup();
@@ -50,7 +49,7 @@ fn query_prepared(c: &mut Criterion) {
5049
}
5150
tx.send(start.elapsed()).unwrap();
5251
});
53-
executor::block_on(rx).unwrap()
52+
futures_executor::block_on(rx).unwrap()
5453
})
5554
});
5655
}

tokio-postgres/src/binary_copy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::types::{FromSql, IsNull, ToSql, Type, WrongType};
44
use crate::{slice_iter, CopyInSink, CopyOutStream, Error};
55
use byteorder::{BigEndian, ByteOrder};
66
use bytes::{Buf, BufMut, Bytes, BytesMut};
7-
use futures::{ready, SinkExt, Stream};
7+
use futures_util::{ready, SinkExt, Stream};
88
use pin_project_lite::pin_project;
99
use postgres_types::BorrowToSql;
1010
use std::convert::TryFrom;

tokio-postgres/src/client.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use crate::{
1818
};
1919
use bytes::{Buf, BytesMut};
2020
use fallible_iterator::FallibleIterator;
21-
use futures::channel::mpsc;
22-
use futures::{future, pin_mut, ready, StreamExt, TryStreamExt};
21+
use futures_channel::mpsc;
22+
use futures_util::{future, pin_mut, ready, StreamExt, TryStreamExt};
2323
use parking_lot::Mutex;
2424
use postgres_protocol::message::{backend::Message, frontend};
2525
use postgres_types::BorrowToSql;
@@ -341,7 +341,7 @@ impl Client {
341341
/// ```no_run
342342
/// # async fn async_main(client: &tokio_postgres::Client) -> Result<(), tokio_postgres::Error> {
343343
/// use tokio_postgres::types::ToSql;
344-
/// use futures::{pin_mut, TryStreamExt};
344+
/// use futures_util::{pin_mut, TryStreamExt};
345345
///
346346
/// let params: Vec<String> = vec![
347347
/// "first param".into(),

tokio-postgres/src/config.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::{error, fmt, iter, mem};
2323
use tokio::io::{AsyncRead, AsyncWrite};
2424

2525
/// Properties required of a session.
26-
#[derive(Debug, Copy, Clone, PartialEq)]
26+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
2727
#[non_exhaustive]
2828
pub enum TargetSessionAttrs {
2929
/// No special properties are required.
@@ -33,7 +33,7 @@ pub enum TargetSessionAttrs {
3333
}
3434

3535
/// TLS configuration.
36-
#[derive(Debug, Copy, Clone, PartialEq)]
36+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
3737
#[non_exhaustive]
3838
pub enum SslMode {
3939
/// Do not use TLS.
@@ -45,7 +45,7 @@ pub enum SslMode {
4545
}
4646

4747
/// Channel binding configuration.
48-
#[derive(Debug, Copy, Clone, PartialEq)]
48+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
4949
#[non_exhaustive]
5050
pub enum ChannelBinding {
5151
/// Do not use channel binding.
@@ -57,7 +57,7 @@ pub enum ChannelBinding {
5757
}
5858

5959
/// A host specification.
60-
#[derive(Debug, Clone, PartialEq)]
60+
#[derive(Debug, Clone, PartialEq, Eq)]
6161
pub enum Host {
6262
/// A TCP hostname.
6363
Tcp(String),
@@ -144,7 +144,7 @@ pub enum Host {
144144
/// ```not_rust
145145
/// postgresql:///mydb?user=user&host=/var/lib/postgresql
146146
/// ```
147-
#[derive(PartialEq, Clone)]
147+
#[derive(Clone, PartialEq, Eq)]
148148
pub struct Config {
149149
pub(crate) user: Option<String>,
150150
pub(crate) password: Option<Vec<u8>>,
@@ -452,7 +452,7 @@ impl Config {
452452
}
453453
}
454454
"target_session_attrs" => {
455-
let target_session_attrs = match &*value {
455+
let target_session_attrs = match value {
456456
"any" => TargetSessionAttrs::Any,
457457
"read-write" => TargetSessionAttrs::ReadWrite,
458458
_ => {
@@ -900,7 +900,7 @@ impl<'a> UrlParser<'a> {
900900
#[cfg(unix)]
901901
fn host_param(&mut self, s: &str) -> Result<(), Error> {
902902
let decoded = Cow::from(percent_encoding::percent_decode(s.as_bytes()));
903-
if decoded.get(0) == Some(&b'/') {
903+
if decoded.first() == Some(&b'/') {
904904
self.config.host_path(OsStr::from_bytes(&decoded));
905905
} else {
906906
let decoded = str::from_utf8(&decoded).map_err(|e| Error::config_parse(Box::new(e)))?;

tokio-postgres/src/connect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::connect_raw::connect_raw;
44
use crate::connect_socket::connect_socket;
55
use crate::tls::{MakeTlsConnect, TlsConnect};
66
use crate::{Client, Config, Connection, Error, SimpleQueryMessage, Socket};
7-
use futures::{future, pin_mut, Future, FutureExt, Stream};
7+
use futures_util::{future, pin_mut, Future, FutureExt, Stream};
88
use std::io;
99
use std::task::Poll;
1010

@@ -28,7 +28,7 @@ where
2828
let port = config
2929
.port
3030
.get(i)
31-
.or_else(|| config.port.get(0))
31+
.or_else(|| config.port.first())
3232
.copied()
3333
.unwrap_or(5432);
3434

tokio-postgres/src/connect_raw.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use crate::tls::{TlsConnect, TlsStream};
66
use crate::{Client, Connection, Error};
77
use bytes::BytesMut;
88
use fallible_iterator::FallibleIterator;
9-
use futures::channel::mpsc;
10-
use futures::{ready, Sink, SinkExt, Stream, TryStreamExt};
9+
use futures_channel::mpsc;
10+
use futures_util::{ready, Sink, SinkExt, Stream, TryStreamExt};
1111
use postgres_protocol::authentication;
1212
use postgres_protocol::authentication::sasl;
1313
use postgres_protocol::authentication::sasl::ScramSha256;

tokio-postgres/src/connection.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ use crate::maybe_tls_stream::MaybeTlsStream;
55
use crate::{AsyncMessage, Error, Notification};
66
use bytes::BytesMut;
77
use fallible_iterator::FallibleIterator;
8-
use futures::channel::mpsc;
9-
use futures::stream::FusedStream;
10-
use futures::{ready, Sink, Stream, StreamExt};
8+
use futures_channel::mpsc;
9+
use futures_util::{ready, stream::FusedStream, Sink, Stream, StreamExt};
1110
use log::{info, trace};
1211
use postgres_protocol::message::backend::Message;
1312
use postgres_protocol::message::frontend;

tokio-postgres/src/copy_in.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ use crate::codec::FrontendMessage;
33
use crate::connection::RequestMessages;
44
use crate::{query, slice_iter, Error, Statement};
55
use bytes::{Buf, BufMut, BytesMut};
6-
use futures::channel::mpsc;
7-
use futures::future;
8-
use futures::{ready, Sink, SinkExt, Stream, StreamExt};
6+
use futures_channel::mpsc;
7+
use futures_util::{future, ready, Sink, SinkExt, Stream, StreamExt};
98
use log::debug;
109
use pin_project_lite::pin_project;
1110
use postgres_protocol::message::backend::Message;

tokio-postgres/src/copy_out.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::codec::FrontendMessage;
33
use crate::connection::RequestMessages;
44
use crate::{query, slice_iter, Error, Statement};
55
use bytes::Bytes;
6-
use futures::{ready, Stream};
6+
use futures_util::{ready, Stream};
77
use log::debug;
88
use pin_project_lite::pin_project;
99
use postgres_protocol::message::backend::Message;

tokio-postgres/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
//! combinator):
7070
//!
7171
//! ```rust
72-
//! use futures::future;
72+
//! use futures_util::future;
7373
//! use std::future::Future;
7474
//! use tokio_postgres::{Client, Error, Statement};
7575
//!

tokio-postgres/src/prepare.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{query, slice_iter};
77
use crate::{Column, Error, Statement};
88
use bytes::Bytes;
99
use fallible_iterator::FallibleIterator;
10-
use futures::{pin_mut, TryStreamExt};
10+
use futures_util::{pin_mut, TryStreamExt};
1111
use log::debug;
1212
use postgres_protocol::message::backend::Message;
1313
use postgres_protocol::message::frontend;

tokio-postgres/src/query.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::connection::RequestMessages;
44
use crate::types::{BorrowToSql, IsNull};
55
use crate::{Error, Portal, Row, Statement};
66
use bytes::{Bytes, BytesMut};
7-
use futures::{ready, Stream};
7+
use futures_util::{ready, Stream};
88
use log::{debug, log_enabled, Level};
99
use pin_project_lite::pin_project;
1010
use postgres_protocol::message::backend::Message;

tokio-postgres/src/simple_query.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::connection::RequestMessages;
44
use crate::{Error, SimpleQueryMessage, SimpleQueryRow};
55
use bytes::Bytes;
66
use fallible_iterator::FallibleIterator;
7-
use futures::{ready, Stream};
7+
use futures_util::{ready, Stream};
88
use log::debug;
99
use pin_project_lite::pin_project;
1010
use postgres_protocol::message::backend::Message;

tokio-postgres/src/transaction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313
SimpleQueryMessage, Statement, ToStatement,
1414
};
1515
use bytes::Buf;
16-
use futures::TryStreamExt;
16+
use futures_util::TryStreamExt;
1717
use postgres_protocol::message::frontend;
1818
use tokio::io::{AsyncRead, AsyncWrite};
1919

tokio-postgres/tests/test/binary_copy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::connect;
2-
use futures::{pin_mut, TryStreamExt};
2+
use futures_util::{pin_mut, TryStreamExt};
33
use tokio_postgres::binary_copy::{BinaryCopyInWriter, BinaryCopyOutStream};
44
use tokio_postgres::types::Type;
55

0 commit comments

Comments
 (0)