Rename cargo features in preparation for rustls support

This commit is contained in:
Jonas Platte
2020-10-20 12:29:24 +02:00
committed by Ryan Leckey
parent 04f68632b4
commit a161bcba05
23 changed files with 203 additions and 164 deletions

View File

@@ -16,7 +16,7 @@ authors = [
features = ["all-databases", "all-types", "offline"]
[features]
default = [ "runtime-async-std", "migrate" ]
default = [ "runtime-async-std-native-tls", "migrate" ]
migrate = [ "sha2", "crc" ]
# databases
@@ -34,9 +34,14 @@ decimal = [ "rust_decimal", "num-bigint" ]
json = [ "serde", "serde_json" ]
# runtimes
runtime-async-std = [ "sqlx-rt/runtime-async-std" ]
runtime-tokio = [ "sqlx-rt/runtime-tokio" ]
runtime-actix = [ "sqlx-rt/runtime-actix" ]
runtime-actix-native-tls = [ "sqlx-rt/runtime-actix-native-tls", "_rt-actix" ]
runtime-async-std-native-tls = [ "sqlx-rt/runtime-async-std-native-tls", "_rt-async-std" ]
runtime-tokio-native-tls = [ "sqlx-rt/runtime-tokio-native-tls", "_rt-tokio" ]
# for conditional compilation
_rt-actix = []
_rt-async-std = []
_rt-tokio = []
# support offline/decoupled building (enables serialization of `Describe`)
offline = [ "serde", "either/serde" ]

View File

@@ -67,10 +67,10 @@ async fn upgrade(stream: &mut MySqlStream, options: &MySqlConnectOptions) -> Res
}
}
#[cfg(not(feature = "runtime-async-std"))]
#[cfg(not(feature = "_rt-async-std"))]
let connector = builder.build().map_err(Error::tls)?;
#[cfg(feature = "runtime-async-std")]
#[cfg(feature = "_rt-async-std")]
let connector = builder;
stream.upgrade(&options.host, connector.into()).await?;

View File

@@ -35,7 +35,7 @@ pub use ssl_mode::MySqlSslMode;
/// # use sqlx_core::mysql::{MySqlConnectOptions, MySqlConnection, MySqlSslMode};
/// #
/// # fn main() {
/// # #[cfg(feature = "runtime-async-std")]
/// # #[cfg(feature = "_rt-async-std")]
/// # sqlx_rt::async_std::task::block_on::<_, Result<(), Error>>(async move {
/// // URI connection string
/// let conn = MySqlConnection::connect("mysql://root:password@localhost/db").await?;

View File

@@ -60,7 +60,7 @@ impl AsyncRead for Socket {
}
}
#[cfg(any(feature = "runtime-actix", feature = "runtime-tokio"))]
#[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))]
fn poll_read_buf<B>(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
@@ -102,7 +102,7 @@ impl AsyncWrite for Socket {
}
}
#[cfg(any(feature = "runtime-actix", feature = "runtime-tokio"))]
#[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))]
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
match &mut *self {
Socket::Tcp(s) => Pin::new(s).poll_shutdown(cx),
@@ -112,7 +112,7 @@ impl AsyncWrite for Socket {
}
}
#[cfg(feature = "runtime-async-std")]
#[cfg(feature = "_rt-async-std")]
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
match &mut *self {
Socket::Tcp(s) => Pin::new(s).poll_close(cx),
@@ -122,7 +122,7 @@ impl AsyncWrite for Socket {
}
}
#[cfg(any(feature = "runtime-actix", feature = "runtime-tokio"))]
#[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))]
fn poll_write_buf<B>(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,

View File

@@ -72,7 +72,7 @@ where
}
}
#[cfg(any(feature = "runtime-actix", feature = "runtime-tokio"))]
#[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))]
fn poll_read_buf<B>(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
@@ -117,7 +117,7 @@ where
}
}
#[cfg(any(feature = "runtime-actix", feature = "runtime-tokio"))]
#[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))]
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
match &mut *self {
MaybeTlsStream::Raw(s) => Pin::new(s).poll_shutdown(cx),
@@ -127,7 +127,7 @@ where
}
}
#[cfg(feature = "runtime-async-std")]
#[cfg(feature = "_rt-async-std")]
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
match &mut *self {
MaybeTlsStream::Raw(s) => Pin::new(s).poll_close(cx),
@@ -137,7 +137,7 @@ where
}
}
#[cfg(any(feature = "runtime-actix", feature = "runtime-tokio"))]
#[cfg(any(feature = "_rt-actix", feature = "_rt-tokio"))]
fn poll_write_buf<B>(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
@@ -166,10 +166,10 @@ where
match self {
MaybeTlsStream::Raw(s) => s,
#[cfg(not(feature = "runtime-async-std"))]
#[cfg(not(feature = "_rt-async-std"))]
MaybeTlsStream::Tls(s) => s.get_ref().get_ref().get_ref(),
#[cfg(feature = "runtime-async-std")]
#[cfg(feature = "_rt-async-std")]
MaybeTlsStream::Tls(s) => s.get_ref(),
MaybeTlsStream::Upgrading => panic!(io::Error::from(io::ErrorKind::ConnectionAborted)),
@@ -185,10 +185,10 @@ where
match self {
MaybeTlsStream::Raw(s) => s,
#[cfg(not(feature = "runtime-async-std"))]
#[cfg(not(feature = "_rt-async-std"))]
MaybeTlsStream::Tls(s) => s.get_mut().get_mut().get_mut(),
#[cfg(feature = "runtime-async-std")]
#[cfg(feature = "_rt-async-std")]
MaybeTlsStream::Tls(s) => s.get_mut(),
MaybeTlsStream::Upgrading => panic!(io::Error::from(io::ErrorKind::ConnectionAborted)),

View File

@@ -84,10 +84,10 @@ async fn upgrade(stream: &mut PgStream, options: &PgConnectOptions) -> Result<bo
}
}
#[cfg(not(feature = "runtime-async-std"))]
#[cfg(not(feature = "_rt-async-std"))]
let connector = builder.build().map_err(Error::tls)?;
#[cfg(feature = "runtime-async-std")]
#[cfg(feature = "_rt-async-std")]
let connector = builder;
stream.upgrade(&options.host, connector.into()).await?;

View File

@@ -150,7 +150,7 @@ impl PgListener {
/// # use sqlx_core::postgres::PgListener;
/// # use sqlx_core::error::Error;
/// #
/// # #[cfg(feature = "runtime-async-std")]
/// # #[cfg(feature = "_rt-async-std")]
/// # sqlx_rt::block_on::<_, Result<(), Error>>(async move {
/// # let mut listener = PgListener::connect("postgres:// ...").await?;
/// loop {
@@ -183,7 +183,7 @@ impl PgListener {
/// # use sqlx_core::postgres::PgListener;
/// # use sqlx_core::error::Error;
/// #
/// # #[cfg(feature = "runtime-async-std")]
/// # #[cfg(feature = "_rt-async-std")]
/// # sqlx_rt::block_on::<_, Result<(), Error>>(async move {
/// # let mut listener = PgListener::connect("postgres:// ...").await?;
/// loop {

View File

@@ -54,7 +54,7 @@ pub use ssl_mode::PgSslMode;
/// # use sqlx_core::postgres::{PgConnectOptions, PgConnection, PgSslMode};
/// #
/// # fn main() {
/// # #[cfg(feature = "runtime-async-std")]
/// # #[cfg(feature = "_rt-async-std")]
/// # sqlx_rt::async_std::task::block_on::<_, Result<(), Error>>(async move {
/// // URI connection string
/// let conn = PgConnection::connect("postgres://localhost/mydb").await?;

View File

@@ -31,7 +31,7 @@ use std::{borrow::Cow, time::Duration};
/// use std::str::FromStr;
///
/// # fn main() {
/// # #[cfg(feature = "runtime-async-std")]
/// # #[cfg(feature = "_rt-async-std")]
/// # sqlx_rt::async_std::task::block_on::<_, Result<(), Error>>(async move {
/// let conn = SqliteConnectOptions::from_str("sqlite://data.db")?
/// .journal_mode(SqliteJournalMode::Wal)