Rename handshake to connect_raw
This commit is contained in:
parent
3a01c8c3a3
commit
5b045940f4
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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<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))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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>,
|
||||
|
@ -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<Socket, T>,
|
||||
ConnectingRaw {
|
||||
future: ConnectRawFuture<Socket, T>,
|
||||
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<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 {
|
||||
|
@ -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>,
|
||||
@ -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>,
|
||||
@ -374,7 +374,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, T> HandshakeFuture<S, T>
|
||||
impl<S, T> ConnectRawFuture<S, T>
|
||||
where
|
||||
S: AsyncRead + AsyncWrite,
|
||||
T: TlsMode<S>,
|
||||
@ -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)
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user