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())
|
let handshake = TcpStream::connect(&"127.0.0.1:5433".parse().unwrap())
|
||||||
.map_err(|e| panic!("{}", e))
|
.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 (mut client, connection) = runtime.block_on(handshake).unwrap();
|
||||||
let connection = connection.map_err(|e| panic!("{}", e));
|
let connection = connection.map_err(|e| panic!("{}", e));
|
||||||
runtime.spawn(connection);
|
runtime.spawn(connection);
|
||||||
|
@ -17,7 +17,7 @@ where
|
|||||||
|
|
||||||
let handshake = TcpStream::connect(&"127.0.0.1:5433".parse().unwrap())
|
let handshake = TcpStream::connect(&"127.0.0.1:5433".parse().unwrap())
|
||||||
.map_err(|e| panic!("{}", e))
|
.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 (mut client, connection) = runtime.block_on(handshake).unwrap();
|
||||||
let connection = connection.map_err(|e| panic!("{}", e));
|
let connection = connection.map_err(|e| panic!("{}", e));
|
||||||
runtime.spawn(connection);
|
runtime.spawn(connection);
|
||||||
|
@ -17,10 +17,10 @@ use tokio_io::{AsyncRead, AsyncWrite};
|
|||||||
|
|
||||||
#[cfg(feature = "runtime")]
|
#[cfg(feature = "runtime")]
|
||||||
use crate::proto::ConnectFuture;
|
use crate::proto::ConnectFuture;
|
||||||
use crate::proto::HandshakeFuture;
|
use crate::proto::ConnectRawFuture;
|
||||||
#[cfg(feature = "runtime")]
|
#[cfg(feature = "runtime")]
|
||||||
use crate::{Connect, MakeTlsMode, Socket};
|
use crate::{Connect, MakeTlsMode, Socket};
|
||||||
use crate::{Error, Handshake, TlsMode};
|
use crate::{ConnectRaw, Error, TlsMode};
|
||||||
|
|
||||||
/// Properties required of a database.
|
/// Properties required of a database.
|
||||||
#[cfg(feature = "runtime")]
|
#[cfg(feature = "runtime")]
|
||||||
@ -400,12 +400,12 @@ impl Config {
|
|||||||
/// Connects to a PostgreSQL database over an arbitrary stream.
|
/// Connects to a PostgreSQL database over an arbitrary stream.
|
||||||
///
|
///
|
||||||
/// All of the settings other than `user`, `password`, `dbname`, `options`, and `application` name are ignored.
|
/// 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
|
where
|
||||||
S: AsyncRead + AsyncWrite,
|
S: AsyncRead + AsyncWrite,
|
||||||
T: TlsMode<S>,
|
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"]
|
#[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
|
where
|
||||||
S: AsyncRead + AsyncWrite,
|
S: AsyncRead + AsyncWrite,
|
||||||
T: TlsMode<S>;
|
T: TlsMode<S>;
|
||||||
|
|
||||||
impl<S, T> Future for Handshake<S, T>
|
impl<S, T> Future for ConnectRaw<S, T>
|
||||||
where
|
where
|
||||||
S: AsyncRead + AsyncWrite,
|
S: AsyncRead + AsyncWrite,
|
||||||
T: TlsMode<S>,
|
T: TlsMode<S>,
|
||||||
|
@ -4,7 +4,7 @@ use futures::{try_ready, Async, Future, Poll, Stream};
|
|||||||
use state_machine_future::{transition, RentToOwn, StateMachineFuture};
|
use state_machine_future::{transition, RentToOwn, StateMachineFuture};
|
||||||
use std::io;
|
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};
|
use crate::{Config, Error, Socket, TargetSessionAttrs, TlsMode};
|
||||||
|
|
||||||
#[derive(StateMachineFuture)]
|
#[derive(StateMachineFuture)]
|
||||||
@ -18,7 +18,7 @@ where
|
|||||||
tls_mode: T,
|
tls_mode: T,
|
||||||
config: Config,
|
config: Config,
|
||||||
},
|
},
|
||||||
#[state_machine_future(transitions(Handshaking))]
|
#[state_machine_future(transitions(ConnectingRaw))]
|
||||||
ConnectingSocket {
|
ConnectingSocket {
|
||||||
future: ConnectSocketFuture,
|
future: ConnectSocketFuture,
|
||||||
idx: usize,
|
idx: usize,
|
||||||
@ -26,8 +26,8 @@ where
|
|||||||
config: Config,
|
config: Config,
|
||||||
},
|
},
|
||||||
#[state_machine_future(transitions(CheckingSessionAttrs, Finished))]
|
#[state_machine_future(transitions(CheckingSessionAttrs, Finished))]
|
||||||
Handshaking {
|
ConnectingRaw {
|
||||||
future: HandshakeFuture<Socket, T>,
|
future: ConnectRawFuture<Socket, T>,
|
||||||
target_session_attrs: TargetSessionAttrs,
|
target_session_attrs: TargetSessionAttrs,
|
||||||
},
|
},
|
||||||
#[state_machine_future(transitions(Finished))]
|
#[state_machine_future(transitions(Finished))]
|
||||||
@ -63,15 +63,15 @@ where
|
|||||||
let socket = try_ready!(state.future.poll());
|
let socket = try_ready!(state.future.poll());
|
||||||
let state = state.take();
|
let state = state.take();
|
||||||
|
|
||||||
transition!(Handshaking {
|
transition!(ConnectingRaw {
|
||||||
target_session_attrs: state.config.0.target_session_attrs,
|
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>(
|
fn poll_connecting_raw<'a>(
|
||||||
state: &'a mut RentToOwn<'a, Handshaking<T>>,
|
state: &'a mut RentToOwn<'a, ConnectingRaw<T>>,
|
||||||
) -> Poll<AfterHandshaking<T>, Error> {
|
) -> Poll<AfterConnectingRaw<T>, Error> {
|
||||||
let (client, connection) = try_ready!(state.future.poll());
|
let (client, connection) = try_ready!(state.future.poll());
|
||||||
|
|
||||||
if let TargetSessionAttrs::ReadWrite = state.target_session_attrs {
|
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};
|
use crate::{ChannelBinding, Config, Error, TlsMode};
|
||||||
|
|
||||||
#[derive(StateMachineFuture)]
|
#[derive(StateMachineFuture)]
|
||||||
pub enum Handshake<S, T>
|
pub enum ConnectRaw<S, T>
|
||||||
where
|
where
|
||||||
S: AsyncRead + AsyncWrite,
|
S: AsyncRead + AsyncWrite,
|
||||||
T: TlsMode<S>,
|
T: TlsMode<S>,
|
||||||
@ -81,7 +81,7 @@ where
|
|||||||
Failed(Error),
|
Failed(Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S, T> PollHandshake<S, T> for Handshake<S, T>
|
impl<S, T> PollConnectRaw<S, T> for ConnectRaw<S, T>
|
||||||
where
|
where
|
||||||
S: AsyncRead + AsyncWrite,
|
S: AsyncRead + AsyncWrite,
|
||||||
T: TlsMode<S>,
|
T: TlsMode<S>,
|
||||||
@ -374,7 +374,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S, T> HandshakeFuture<S, T>
|
impl<S, T> ConnectRawFuture<S, T>
|
||||||
where
|
where
|
||||||
S: AsyncRead + AsyncWrite,
|
S: AsyncRead + AsyncWrite,
|
||||||
T: TlsMode<S>,
|
T: TlsMode<S>,
|
||||||
@ -384,7 +384,7 @@ where
|
|||||||
tls_mode: T,
|
tls_mode: T,
|
||||||
config: Config,
|
config: Config,
|
||||||
idx: Option<usize>,
|
idx: Option<usize>,
|
||||||
) -> HandshakeFuture<S, T> {
|
) -> ConnectRawFuture<S, T> {
|
||||||
Handshake::start(TlsFuture::new(stream, tls_mode), config, idx)
|
ConnectRaw::start(TlsFuture::new(stream, tls_mode), config, idx)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -28,13 +28,13 @@ mod codec;
|
|||||||
mod connect;
|
mod connect;
|
||||||
#[cfg(feature = "runtime")]
|
#[cfg(feature = "runtime")]
|
||||||
mod connect_once;
|
mod connect_once;
|
||||||
|
mod connect_raw;
|
||||||
#[cfg(feature = "runtime")]
|
#[cfg(feature = "runtime")]
|
||||||
mod connect_socket;
|
mod connect_socket;
|
||||||
mod connection;
|
mod connection;
|
||||||
mod copy_in;
|
mod copy_in;
|
||||||
mod copy_out;
|
mod copy_out;
|
||||||
mod execute;
|
mod execute;
|
||||||
mod handshake;
|
|
||||||
mod idle;
|
mod idle;
|
||||||
mod portal;
|
mod portal;
|
||||||
mod prepare;
|
mod prepare;
|
||||||
@ -57,13 +57,13 @@ pub use crate::proto::codec::PostgresCodec;
|
|||||||
pub use crate::proto::connect::ConnectFuture;
|
pub use crate::proto::connect::ConnectFuture;
|
||||||
#[cfg(feature = "runtime")]
|
#[cfg(feature = "runtime")]
|
||||||
pub use crate::proto::connect_once::ConnectOnceFuture;
|
pub use crate::proto::connect_once::ConnectOnceFuture;
|
||||||
|
pub use crate::proto::connect_raw::ConnectRawFuture;
|
||||||
#[cfg(feature = "runtime")]
|
#[cfg(feature = "runtime")]
|
||||||
pub use crate::proto::connect_socket::ConnectSocketFuture;
|
pub use crate::proto::connect_socket::ConnectSocketFuture;
|
||||||
pub use crate::proto::connection::Connection;
|
pub use crate::proto::connection::Connection;
|
||||||
pub use crate::proto::copy_in::CopyInFuture;
|
pub use crate::proto::copy_in::CopyInFuture;
|
||||||
pub use crate::proto::copy_out::CopyOutStream;
|
pub use crate::proto::copy_out::CopyOutStream;
|
||||||
pub use crate::proto::execute::ExecuteFuture;
|
pub use crate::proto::execute::ExecuteFuture;
|
||||||
pub use crate::proto::handshake::HandshakeFuture;
|
|
||||||
pub use crate::proto::portal::Portal;
|
pub use crate::proto::portal::Portal;
|
||||||
pub use crate::proto::prepare::PrepareFuture;
|
pub use crate::proto::prepare::PrepareFuture;
|
||||||
pub use crate::proto::query::QueryStream;
|
pub use crate::proto::query::QueryStream;
|
||||||
|
@ -25,7 +25,7 @@ fn connect(
|
|||||||
let builder = s.parse::<tokio_postgres::Config>().unwrap();
|
let builder = s.parse::<tokio_postgres::Config>().unwrap();
|
||||||
TcpStream::connect(&"127.0.0.1:5433".parse().unwrap())
|
TcpStream::connect(&"127.0.0.1:5433".parse().unwrap())
|
||||||
.map_err(|e| panic!("{}", e))
|
.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) {
|
fn smoke_test(s: &str) {
|
||||||
|
Loading…
Reference in New Issue
Block a user