From 5b045940f4fe739be96c5c49ff22a827eb7103b8 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 7 Jan 2019 21:45:09 -0800 Subject: [PATCH] Rename handshake to connect_raw --- tokio-postgres-native-tls/src/test.rs | 2 +- tokio-postgres-openssl/src/test.rs | 2 +- tokio-postgres/src/config.rs | 8 ++++---- tokio-postgres/src/lib.rs | 4 ++-- tokio-postgres/src/proto/connect_once.rs | 18 +++++++++--------- .../src/proto/{handshake.rs => connect_raw.rs} | 10 +++++----- tokio-postgres/src/proto/mod.rs | 4 ++-- tokio-postgres/tests/test/main.rs | 2 +- 8 files changed, 25 insertions(+), 25 deletions(-) rename tokio-postgres/src/proto/{handshake.rs => connect_raw.rs} (98%) diff --git a/tokio-postgres-native-tls/src/test.rs b/tokio-postgres-native-tls/src/test.rs index dda907f4..cbb12187 100644 --- a/tokio-postgres-native-tls/src/test.rs +++ b/tokio-postgres-native-tls/src/test.rs @@ -17,7 +17,7 @@ where let handshake = TcpStream::connect(&"127.0.0.1:5433".parse().unwrap()) .map_err(|e| panic!("{}", e)) - .and_then(|s| builder.handshake(s, tls)); + .and_then(|s| builder.connect_raw(s, tls)); let (mut client, connection) = runtime.block_on(handshake).unwrap(); let connection = connection.map_err(|e| panic!("{}", e)); runtime.spawn(connection); diff --git a/tokio-postgres-openssl/src/test.rs b/tokio-postgres-openssl/src/test.rs index 9a123849..aa0e3804 100644 --- a/tokio-postgres-openssl/src/test.rs +++ b/tokio-postgres-openssl/src/test.rs @@ -17,7 +17,7 @@ where let handshake = TcpStream::connect(&"127.0.0.1:5433".parse().unwrap()) .map_err(|e| panic!("{}", e)) - .and_then(|s| builder.handshake(s, tls)); + .and_then(|s| builder.connect_raw(s, tls)); let (mut client, connection) = runtime.block_on(handshake).unwrap(); let connection = connection.map_err(|e| panic!("{}", e)); runtime.spawn(connection); diff --git a/tokio-postgres/src/config.rs b/tokio-postgres/src/config.rs index 57553a71..002dea7c 100644 --- a/tokio-postgres/src/config.rs +++ b/tokio-postgres/src/config.rs @@ -17,10 +17,10 @@ use tokio_io::{AsyncRead, AsyncWrite}; #[cfg(feature = "runtime")] use crate::proto::ConnectFuture; -use crate::proto::HandshakeFuture; +use crate::proto::ConnectRawFuture; #[cfg(feature = "runtime")] use crate::{Connect, MakeTlsMode, Socket}; -use crate::{Error, Handshake, TlsMode}; +use crate::{ConnectRaw, Error, TlsMode}; /// Properties required of a database. #[cfg(feature = "runtime")] @@ -400,12 +400,12 @@ impl Config { /// Connects to a PostgreSQL database over an arbitrary stream. /// /// All of the settings other than `user`, `password`, `dbname`, `options`, and `application` name are ignored. - pub fn handshake(&self, stream: S, tls_mode: T) -> Handshake + pub fn connect_raw(&self, stream: S, tls_mode: T) -> ConnectRaw where S: AsyncRead + AsyncWrite, T: TlsMode, { - Handshake(HandshakeFuture::new(stream, tls_mode, self.clone(), None)) + ConnectRaw(ConnectRawFuture::new(stream, tls_mode, self.clone(), None)) } } diff --git a/tokio-postgres/src/lib.rs b/tokio-postgres/src/lib.rs index e27ca1d8..6e4ee3c7 100644 --- a/tokio-postgres/src/lib.rs +++ b/tokio-postgres/src/lib.rs @@ -377,12 +377,12 @@ where } #[must_use = "futures do nothing unless polled"] -pub struct Handshake(proto::HandshakeFuture) +pub struct ConnectRaw(proto::ConnectRawFuture) where S: AsyncRead + AsyncWrite, T: TlsMode; -impl Future for Handshake +impl Future for ConnectRaw where S: AsyncRead + AsyncWrite, T: TlsMode, diff --git a/tokio-postgres/src/proto/connect_once.rs b/tokio-postgres/src/proto/connect_once.rs index c784e2d7..2f73df19 100644 --- a/tokio-postgres/src/proto/connect_once.rs +++ b/tokio-postgres/src/proto/connect_once.rs @@ -4,7 +4,7 @@ use futures::{try_ready, Async, Future, Poll, Stream}; use state_machine_future::{transition, RentToOwn, StateMachineFuture}; use std::io; -use crate::proto::{Client, ConnectSocketFuture, Connection, HandshakeFuture, SimpleQueryStream}; +use crate::proto::{Client, ConnectRawFuture, ConnectSocketFuture, Connection, SimpleQueryStream}; use crate::{Config, Error, Socket, TargetSessionAttrs, TlsMode}; #[derive(StateMachineFuture)] @@ -18,7 +18,7 @@ where tls_mode: T, config: Config, }, - #[state_machine_future(transitions(Handshaking))] + #[state_machine_future(transitions(ConnectingRaw))] ConnectingSocket { future: ConnectSocketFuture, idx: usize, @@ -26,8 +26,8 @@ where config: Config, }, #[state_machine_future(transitions(CheckingSessionAttrs, Finished))] - Handshaking { - future: HandshakeFuture, + ConnectingRaw { + future: ConnectRawFuture, target_session_attrs: TargetSessionAttrs, }, #[state_machine_future(transitions(Finished))] @@ -63,15 +63,15 @@ where let socket = try_ready!(state.future.poll()); let state = state.take(); - transition!(Handshaking { + transition!(ConnectingRaw { target_session_attrs: state.config.0.target_session_attrs, - future: HandshakeFuture::new(socket, state.tls_mode, state.config, Some(state.idx)), + future: ConnectRawFuture::new(socket, state.tls_mode, state.config, Some(state.idx)), }) } - fn poll_handshaking<'a>( - state: &'a mut RentToOwn<'a, Handshaking>, - ) -> Poll, Error> { + fn poll_connecting_raw<'a>( + state: &'a mut RentToOwn<'a, ConnectingRaw>, + ) -> Poll, Error> { let (client, connection) = try_ready!(state.future.poll()); if let TargetSessionAttrs::ReadWrite = state.target_session_attrs { diff --git a/tokio-postgres/src/proto/handshake.rs b/tokio-postgres/src/proto/connect_raw.rs similarity index 98% rename from tokio-postgres/src/proto/handshake.rs rename to tokio-postgres/src/proto/connect_raw.rs index 1d245ae1..23f14562 100644 --- a/tokio-postgres/src/proto/handshake.rs +++ b/tokio-postgres/src/proto/connect_raw.rs @@ -15,7 +15,7 @@ use crate::proto::{Client, Connection, PostgresCodec, TlsFuture}; use crate::{ChannelBinding, Config, Error, TlsMode}; #[derive(StateMachineFuture)] -pub enum Handshake +pub enum ConnectRaw where S: AsyncRead + AsyncWrite, T: TlsMode, @@ -81,7 +81,7 @@ where Failed(Error), } -impl PollHandshake for Handshake +impl PollConnectRaw for ConnectRaw where S: AsyncRead + AsyncWrite, T: TlsMode, @@ -374,7 +374,7 @@ where } } -impl HandshakeFuture +impl ConnectRawFuture where S: AsyncRead + AsyncWrite, T: TlsMode, @@ -384,7 +384,7 @@ where tls_mode: T, config: Config, idx: Option, - ) -> HandshakeFuture { - Handshake::start(TlsFuture::new(stream, tls_mode), config, idx) + ) -> ConnectRawFuture { + ConnectRaw::start(TlsFuture::new(stream, tls_mode), config, idx) } } diff --git a/tokio-postgres/src/proto/mod.rs b/tokio-postgres/src/proto/mod.rs index aff4a0a9..796ded1e 100644 --- a/tokio-postgres/src/proto/mod.rs +++ b/tokio-postgres/src/proto/mod.rs @@ -28,13 +28,13 @@ mod codec; mod connect; #[cfg(feature = "runtime")] mod connect_once; +mod connect_raw; #[cfg(feature = "runtime")] mod connect_socket; mod connection; mod copy_in; mod copy_out; mod execute; -mod handshake; mod idle; mod portal; mod prepare; @@ -57,13 +57,13 @@ pub use crate::proto::codec::PostgresCodec; pub use crate::proto::connect::ConnectFuture; #[cfg(feature = "runtime")] pub use crate::proto::connect_once::ConnectOnceFuture; +pub use crate::proto::connect_raw::ConnectRawFuture; #[cfg(feature = "runtime")] pub use crate::proto::connect_socket::ConnectSocketFuture; pub use crate::proto::connection::Connection; pub use crate::proto::copy_in::CopyInFuture; pub use crate::proto::copy_out::CopyOutStream; pub use crate::proto::execute::ExecuteFuture; -pub use crate::proto::handshake::HandshakeFuture; pub use crate::proto::portal::Portal; pub use crate::proto::prepare::PrepareFuture; pub use crate::proto::query::QueryStream; diff --git a/tokio-postgres/tests/test/main.rs b/tokio-postgres/tests/test/main.rs index fc526510..c770c9f4 100644 --- a/tokio-postgres/tests/test/main.rs +++ b/tokio-postgres/tests/test/main.rs @@ -25,7 +25,7 @@ fn connect( let builder = s.parse::().unwrap(); TcpStream::connect(&"127.0.0.1:5433".parse().unwrap()) .map_err(|e| panic!("{}", e)) - .and_then(move |s| builder.handshake(s, NoTls)) + .and_then(move |s| builder.connect_raw(s, NoTls)) } fn smoke_test(s: &str) {