Skip to content

Deps: prefer sub-crates of futures #935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions postgres-native-tls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ default = ["runtime"]
runtime = ["tokio-postgres/runtime"]

[dependencies]
futures = "0.3"
native-tls = "0.2"
tokio = "1.0"
tokio-native-tls = "0.3"
tokio-postgres = { version = "0.7.0", path = "../tokio-postgres", default-features = false }

[dev-dependencies]
tokio = { version = "1.0", features = ["full"] }
futures-util = "0.3"
tokio = { version = "1.0", features = ["macros", "net", "rt"] }
postgres = { version = "0.19.0", path = "../postgres" }
2 changes: 1 addition & 1 deletion postgres-native-tls/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futures::FutureExt;
use futures_util::FutureExt;
use native_tls::{self, Certificate};
use tokio::net::TcpStream;
use tokio_postgres::tls::TlsConnect;
Expand Down
4 changes: 2 additions & 2 deletions postgres-openssl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ default = ["runtime"]
runtime = ["tokio-postgres/runtime"]

[dependencies]
futures = "0.3"
openssl = "0.10"
tokio = "1.0"
tokio-openssl = "0.6"
tokio-postgres = { version = "0.7.0", path = "../tokio-postgres", default-features = false }

[dev-dependencies]
tokio = { version = "1.0", features = ["full"] }
futures-util = "0.3"
tokio = { version = "1.0", features = ["macros", "net", "rt"] }
postgres = { version = "0.19.0", path = "../postgres" }
5 changes: 4 additions & 1 deletion postgres-openssl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,17 @@ use tokio_postgres::tls::{ChannelBinding, TlsConnect};
#[cfg(test)]
mod test;

type ConfigCallback =
dyn Fn(&mut ConnectConfiguration, &str) -> Result<(), ErrorStack> + Sync + Send;

Comment on lines +76 to +78
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clippy complains if we don't use a type alias here. To be fair, it is a pretty lengthy type declaration. 😅

/// A `MakeTlsConnect` implementation using the `openssl` crate.
///
/// Requires the `runtime` Cargo feature (enabled by default).
#[cfg(feature = "runtime")]
#[derive(Clone)]
pub struct MakeTlsConnector {
connector: SslConnector,
config: Arc<dyn Fn(&mut ConnectConfiguration, &str) -> Result<(), ErrorStack> + Sync + Send>,
config: Arc<ConfigCallback>,
}

#[cfg(feature = "runtime")]
Expand Down
2 changes: 1 addition & 1 deletion postgres-openssl/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futures::FutureExt;
use futures_util::FutureExt;
use openssl::ssl::{SslConnector, SslMethod};
use tokio::net::TcpStream;
use tokio_postgres::tls::TlsConnect;
Expand Down
4 changes: 2 additions & 2 deletions postgres-types/src/special.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{i32, i64};
use crate::{FromSql, IsNull, ToSql, Type};

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

/// A wrapper that can be used to represent infinity with `Type::Timestamp` and `Type::Timestamptz`
/// types.
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Timestamp<T> {
/// Represents `infinity`, a timestamp that is later than all other timestamps.
PosInfinity,
Expand Down
3 changes: 2 additions & 1 deletion postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ with-time-0_3 = ["tokio-postgres/with-time-0_3"]
[dependencies]
bytes = "1.0"
fallible-iterator = "0.2"
futures = "0.3"
futures-util = { version = "0.3", features = ["sink"] }
tokio-postgres = { version = "0.7.6", path = "../tokio-postgres" }

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

[dev-dependencies]
criterion = "0.3"
tokio = { version = "1.0", features = ["rt-multi-thread"] }
2 changes: 1 addition & 1 deletion postgres/src/binary_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::connection::ConnectionRef;
use crate::types::{BorrowToSql, ToSql, Type};
use crate::{CopyInWriter, CopyOutReader, Error};
use fallible_iterator::FallibleIterator;
use futures::StreamExt;
use futures_util::StreamExt;
use std::pin::Pin;
#[doc(inline)]
pub use tokio_postgres::binary_copy::BinaryCopyOutRow;
Expand Down
3 changes: 1 addition & 2 deletions postgres/src/connection.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{Error, Notification};
use futures::future;
use futures::{pin_mut, Stream};
use futures_util::{future, pin_mut, Stream};
use std::collections::VecDeque;
use std::future::Future;
use std::ops::{Deref, DerefMut};
Expand Down
2 changes: 1 addition & 1 deletion postgres/src/copy_in_writer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::connection::ConnectionRef;
use crate::lazy_pin::LazyPin;
use bytes::{Bytes, BytesMut};
use futures::SinkExt;
use futures_util::SinkExt;
use std::io;
use std::io::Write;
use tokio_postgres::{CopyInSink, Error};
Expand Down
2 changes: 1 addition & 1 deletion postgres/src/copy_out_reader.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::connection::ConnectionRef;
use crate::lazy_pin::LazyPin;
use bytes::{Buf, Bytes};
use futures::StreamExt;
use futures_util::StreamExt;
use std::io::{self, BufRead, Read};
use tokio_postgres::CopyOutStream;

Expand Down
2 changes: 1 addition & 1 deletion postgres/src/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::connection::ConnectionRef;
use crate::{Error, Notification};
use fallible_iterator::FallibleIterator;
use futures::{ready, FutureExt};
use futures_util::{ready, FutureExt};
use std::pin::Pin;
use std::task::Poll;
use std::time::Duration;
Expand Down
2 changes: 1 addition & 1 deletion postgres/src/row_iter.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::connection::ConnectionRef;
use fallible_iterator::FallibleIterator;
use futures::StreamExt;
use futures_util::StreamExt;
use std::pin::Pin;
use tokio_postgres::{Error, Row, RowStream};

Expand Down
8 changes: 5 additions & 3 deletions tokio-postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ async-trait = "0.1"
bytes = "1.0"
byteorder = "1.0"
fallible-iterator = "0.2"
futures = "0.3"
futures-channel = { version = "0.3", features = ["sink"] }
futures-util = { version = "0.3", features = ["sink"] }
log = "0.4"
parking_lot = "0.12"
percent-encoding = "2.0"
Expand All @@ -58,9 +59,10 @@ tokio = { version = "1.0", features = ["io-util"] }
tokio-util = { version = "0.7", features = ["codec"] }

[dev-dependencies]
tokio = { version = "1.0", features = ["full"] }
env_logger = "0.9"
futures-executor = "0.3"
criterion = "0.3"
env_logger = "0.9"
tokio = { version = "1.0", features = ["macros", "net", "rt", "rt-multi-thread", "time"] }

bit-vec-06 = { version = "0.6", package = "bit-vec" }
chrono-04 = { version = "0.4", package = "chrono", default-features = false }
Expand Down
7 changes: 3 additions & 4 deletions tokio-postgres/benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use criterion::{criterion_group, criterion_main, Criterion};
use futures::channel::oneshot;
use futures::executor;
use futures_channel::oneshot;
use std::sync::Arc;
use std::time::Instant;
use tokio::runtime::Runtime;
Expand Down Expand Up @@ -32,7 +31,7 @@ fn query_prepared(c: &mut Criterion) {
let (client, runtime) = setup();
let statement = runtime.block_on(client.prepare("SELECT $1::INT8")).unwrap();
c.bench_function("executor_block_on", move |b| {
b.iter(|| executor::block_on(client.query(&statement, &[&1i64])).unwrap())
b.iter(|| futures_executor::block_on(client.query(&statement, &[&1i64])).unwrap())
});

let (client, runtime) = setup();
Expand All @@ -50,7 +49,7 @@ fn query_prepared(c: &mut Criterion) {
}
tx.send(start.elapsed()).unwrap();
});
executor::block_on(rx).unwrap()
futures_executor::block_on(rx).unwrap()
})
});
}
Expand Down
2 changes: 1 addition & 1 deletion tokio-postgres/src/binary_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::types::{FromSql, IsNull, ToSql, Type, WrongType};
use crate::{slice_iter, CopyInSink, CopyOutStream, Error};
use byteorder::{BigEndian, ByteOrder};
use bytes::{Buf, BufMut, Bytes, BytesMut};
use futures::{ready, SinkExt, Stream};
use futures_util::{ready, SinkExt, Stream};
use pin_project_lite::pin_project;
use postgres_types::BorrowToSql;
use std::convert::TryFrom;
Expand Down
6 changes: 3 additions & 3 deletions tokio-postgres/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use crate::{
};
use bytes::{Buf, BytesMut};
use fallible_iterator::FallibleIterator;
use futures::channel::mpsc;
use futures::{future, pin_mut, ready, StreamExt, TryStreamExt};
use futures_channel::mpsc;
use futures_util::{future, pin_mut, ready, StreamExt, TryStreamExt};
use parking_lot::Mutex;
use postgres_protocol::message::{backend::Message, frontend};
use postgres_types::BorrowToSql;
Expand Down Expand Up @@ -341,7 +341,7 @@ impl Client {
/// ```no_run
/// # async fn async_main(client: &tokio_postgres::Client) -> Result<(), tokio_postgres::Error> {
/// use tokio_postgres::types::ToSql;
/// use futures::{pin_mut, TryStreamExt};
/// use futures_util::{pin_mut, TryStreamExt};
///
/// let params: Vec<String> = vec![
/// "first param".into(),
Expand Down
14 changes: 7 additions & 7 deletions tokio-postgres/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::{error, fmt, iter, mem};
use tokio::io::{AsyncRead, AsyncWrite};

/// Properties required of a session.
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum TargetSessionAttrs {
/// No special properties are required.
Expand All @@ -33,7 +33,7 @@ pub enum TargetSessionAttrs {
}

/// TLS configuration.
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum SslMode {
/// Do not use TLS.
Expand All @@ -45,7 +45,7 @@ pub enum SslMode {
}

/// Channel binding configuration.
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum ChannelBinding {
/// Do not use channel binding.
Expand All @@ -57,7 +57,7 @@ pub enum ChannelBinding {
}

/// A host specification.
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Host {
/// A TCP hostname.
Tcp(String),
Expand Down Expand Up @@ -144,7 +144,7 @@ pub enum Host {
/// ```not_rust
/// postgresql:///mydb?user=user&host=/var/lib/postgresql
/// ```
#[derive(PartialEq, Clone)]
#[derive(Clone, PartialEq, Eq)]
pub struct Config {
pub(crate) user: Option<String>,
pub(crate) password: Option<Vec<u8>>,
Expand Down Expand Up @@ -452,7 +452,7 @@ impl Config {
}
}
"target_session_attrs" => {
let target_session_attrs = match &*value {
let target_session_attrs = match value {
"any" => TargetSessionAttrs::Any,
"read-write" => TargetSessionAttrs::ReadWrite,
_ => {
Expand Down Expand Up @@ -900,7 +900,7 @@ impl<'a> UrlParser<'a> {
#[cfg(unix)]
fn host_param(&mut self, s: &str) -> Result<(), Error> {
let decoded = Cow::from(percent_encoding::percent_decode(s.as_bytes()));
if decoded.get(0) == Some(&b'/') {
if decoded.first() == Some(&b'/') {
self.config.host_path(OsStr::from_bytes(&decoded));
} else {
let decoded = str::from_utf8(&decoded).map_err(|e| Error::config_parse(Box::new(e)))?;
Expand Down
4 changes: 2 additions & 2 deletions tokio-postgres/src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::connect_raw::connect_raw;
use crate::connect_socket::connect_socket;
use crate::tls::{MakeTlsConnect, TlsConnect};
use crate::{Client, Config, Connection, Error, SimpleQueryMessage, Socket};
use futures::{future, pin_mut, Future, FutureExt, Stream};
use futures_util::{future, pin_mut, Future, FutureExt, Stream};
use std::io;
use std::task::Poll;

Expand All @@ -28,7 +28,7 @@ where
let port = config
.port
.get(i)
.or_else(|| config.port.get(0))
.or_else(|| config.port.first())
.copied()
.unwrap_or(5432);

Expand Down
4 changes: 2 additions & 2 deletions tokio-postgres/src/connect_raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::tls::{TlsConnect, TlsStream};
use crate::{Client, Connection, Error};
use bytes::BytesMut;
use fallible_iterator::FallibleIterator;
use futures::channel::mpsc;
use futures::{ready, Sink, SinkExt, Stream, TryStreamExt};
use futures_channel::mpsc;
use futures_util::{ready, Sink, SinkExt, Stream, TryStreamExt};
use postgres_protocol::authentication;
use postgres_protocol::authentication::sasl;
use postgres_protocol::authentication::sasl::ScramSha256;
Expand Down
5 changes: 2 additions & 3 deletions tokio-postgres/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ use crate::maybe_tls_stream::MaybeTlsStream;
use crate::{AsyncMessage, Error, Notification};
use bytes::BytesMut;
use fallible_iterator::FallibleIterator;
use futures::channel::mpsc;
use futures::stream::FusedStream;
use futures::{ready, Sink, Stream, StreamExt};
use futures_channel::mpsc;
use futures_util::{ready, stream::FusedStream, Sink, Stream, StreamExt};
use log::{info, trace};
use postgres_protocol::message::backend::Message;
use postgres_protocol::message::frontend;
Expand Down
5 changes: 2 additions & 3 deletions tokio-postgres/src/copy_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ use crate::codec::FrontendMessage;
use crate::connection::RequestMessages;
use crate::{query, slice_iter, Error, Statement};
use bytes::{Buf, BufMut, BytesMut};
use futures::channel::mpsc;
use futures::future;
use futures::{ready, Sink, SinkExt, Stream, StreamExt};
use futures_channel::mpsc;
use futures_util::{future, ready, Sink, SinkExt, Stream, StreamExt};
use log::debug;
use pin_project_lite::pin_project;
use postgres_protocol::message::backend::Message;
Expand Down
2 changes: 1 addition & 1 deletion tokio-postgres/src/copy_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::codec::FrontendMessage;
use crate::connection::RequestMessages;
use crate::{query, slice_iter, Error, Statement};
use bytes::Bytes;
use futures::{ready, Stream};
use futures_util::{ready, Stream};
use log::debug;
use pin_project_lite::pin_project;
use postgres_protocol::message::backend::Message;
Expand Down
2 changes: 1 addition & 1 deletion tokio-postgres/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
//! combinator):
//!
//! ```rust
//! use futures::future;
//! use futures_util::future;
//! use std::future::Future;
//! use tokio_postgres::{Client, Error, Statement};
//!
Expand Down
2 changes: 1 addition & 1 deletion tokio-postgres/src/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{query, slice_iter};
use crate::{Column, Error, Statement};
use bytes::Bytes;
use fallible_iterator::FallibleIterator;
use futures::{pin_mut, TryStreamExt};
use futures_util::{pin_mut, TryStreamExt};
use log::debug;
use postgres_protocol::message::backend::Message;
use postgres_protocol::message::frontend;
Expand Down
2 changes: 1 addition & 1 deletion tokio-postgres/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::connection::RequestMessages;
use crate::types::{BorrowToSql, IsNull};
use crate::{Error, Portal, Row, Statement};
use bytes::{Bytes, BytesMut};
use futures::{ready, Stream};
use futures_util::{ready, Stream};
use log::{debug, log_enabled, Level};
use pin_project_lite::pin_project;
use postgres_protocol::message::backend::Message;
Expand Down
2 changes: 1 addition & 1 deletion tokio-postgres/src/simple_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::connection::RequestMessages;
use crate::{Error, SimpleQueryMessage, SimpleQueryRow};
use bytes::Bytes;
use fallible_iterator::FallibleIterator;
use futures::{ready, Stream};
use futures_util::{ready, Stream};
use log::debug;
use pin_project_lite::pin_project;
use postgres_protocol::message::backend::Message;
Expand Down
2 changes: 1 addition & 1 deletion tokio-postgres/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
SimpleQueryMessage, Statement, ToStatement,
};
use bytes::Buf;
use futures::TryStreamExt;
use futures_util::TryStreamExt;
use postgres_protocol::message::frontend;
use tokio::io::{AsyncRead, AsyncWrite};

Expand Down
2 changes: 1 addition & 1 deletion tokio-postgres/tests/test/binary_copy.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::connect;
use futures::{pin_mut, TryStreamExt};
use futures_util::{pin_mut, TryStreamExt};
use tokio_postgres::binary_copy::{BinaryCopyInWriter, BinaryCopyOutStream};
use tokio_postgres::types::Type;

Expand Down
Loading