Skip to content

Commit

Permalink
Rename handshake to connect_raw
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Jan 8, 2019
1 parent 3a01c8c commit 5b04594
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion tokio-postgres-native-tls/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tokio-postgres-openssl/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions tokio-postgres/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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<S, T>(&self, stream: S, tls_mode: T) -> Handshake<S, T>
pub fn connect_raw<S, T>(&self, stream: S, tls_mode: T) -> ConnectRaw<S, T>
where
S: AsyncRead + AsyncWrite,
T: TlsMode<S>,
{
Handshake(HandshakeFuture::new(stream, tls_mode, self.clone(), None))
ConnectRaw(ConnectRawFuture::new(stream, tls_mode, self.clone(), None))
}
}

Expand Down
4 changes: 2 additions & 2 deletions tokio-postgres/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,12 @@ where
}

#[must_use = "futures do nothing unless polled"]
pub struct Handshake<S, T>(proto::HandshakeFuture<S, T>)
pub struct ConnectRaw<S, T>(proto::ConnectRawFuture<S, T>)
where
S: AsyncRead + AsyncWrite,
T: TlsMode<S>;

impl<S, T> Future for Handshake<S, T>
impl<S, T> Future for ConnectRaw<S, T>
where
S: AsyncRead + AsyncWrite,
T: TlsMode<S>,
Expand Down
18 changes: 9 additions & 9 deletions tokio-postgres/src/proto/connect_once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -18,16 +18,16 @@ where
tls_mode: T,
config: Config,
},
#[state_machine_future(transitions(Handshaking))]
#[state_machine_future(transitions(ConnectingRaw))]
ConnectingSocket {
future: ConnectSocketFuture,
idx: usize,
tls_mode: T,
config: Config,
},
#[state_machine_future(transitions(CheckingSessionAttrs, Finished))]
Handshaking {
future: HandshakeFuture<Socket, T>,
ConnectingRaw {
future: ConnectRawFuture<Socket, T>,
target_session_attrs: TargetSessionAttrs,
},
#[state_machine_future(transitions(Finished))]
Expand Down Expand Up @@ -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<T>>,
) -> Poll<AfterHandshaking<T>, Error> {
fn poll_connecting_raw<'a>(
state: &'a mut RentToOwn<'a, ConnectingRaw<T>>,
) -> Poll<AfterConnectingRaw<T>, Error> {
let (client, connection) = try_ready!(state.future.poll());

if let TargetSessionAttrs::ReadWrite = state.target_session_attrs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::proto::{Client, Connection, PostgresCodec, TlsFuture};
use crate::{ChannelBinding, Config, Error, TlsMode};

#[derive(StateMachineFuture)]
pub enum Handshake<S, T>
pub enum ConnectRaw<S, T>
where
S: AsyncRead + AsyncWrite,
T: TlsMode<S>,
Expand Down Expand Up @@ -81,7 +81,7 @@ where
Failed(Error),
}

impl<S, T> PollHandshake<S, T> for Handshake<S, T>
impl<S, T> PollConnectRaw<S, T> for ConnectRaw<S, T>
where
S: AsyncRead + AsyncWrite,
T: TlsMode<S>,
Expand Down Expand Up @@ -374,7 +374,7 @@ where
}
}

impl<S, T> HandshakeFuture<S, T>
impl<S, T> ConnectRawFuture<S, T>
where
S: AsyncRead + AsyncWrite,
T: TlsMode<S>,
Expand All @@ -384,7 +384,7 @@ where
tls_mode: T,
config: Config,
idx: Option<usize>,
) -> HandshakeFuture<S, T> {
Handshake::start(TlsFuture::new(stream, tls_mode), config, idx)
) -> ConnectRawFuture<S, T> {
ConnectRaw::start(TlsFuture::new(stream, tls_mode), config, idx)
}
}
4 changes: 2 additions & 2 deletions tokio-postgres/src/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tokio-postgres/tests/test/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn connect(
let builder = s.parse::<tokio_postgres::Config>().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) {
Expand Down

0 comments on commit 5b04594

Please sign in to comment.