Skip to content

Commit

Permalink
chore(quaint): rename "*-connector" feature flag to "*-native"
Browse files Browse the repository at this point in the history
  • Loading branch information
jkomyno committed Nov 14, 2023
1 parent e61bf75 commit 257c4c8
Show file tree
Hide file tree
Showing 17 changed files with 66 additions and 74 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ features = [
"pooled",
"postgresql",
"sqlite",
"connectors",
"native",
]

[profile.dev.package.backtrace]
Expand Down
20 changes: 10 additions & 10 deletions quaint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ docs = []
# way to access database-specific methods when you need extra control.
expose-drivers = []

connectors = [
"postgresql-connector",
"mysql-connector",
"mssql-connector",
"sqlite-connector",
native = [
"postgresql-native",
"mysql-native",
"mssql-native",
"sqlite-native",
]

all = ["connectors", "pooled"]
all = ["native", "pooled"]

vendored-openssl = [
"postgres-native-tls/vendored-openssl",
"mysql_async/vendored-openssl",
]

postgresql-connector = [
postgresql-native = [
"postgresql",
"native-tls",
"tokio-postgres",
Expand All @@ -57,7 +57,7 @@ postgresql-connector = [
]
postgresql = []

mssql-connector = [
mssql-native = [
"mssql",
"tiberius",
"tokio-util",
Expand All @@ -66,11 +66,11 @@ mssql-connector = [
]
mssql = []

mysql-connector = ["mysql", "mysql_async", "tokio/time", "lru-cache"]
mysql-native = ["mysql", "mysql_async", "tokio/time", "lru-cache"]
mysql = ["chrono/std"]

pooled = ["mobc"]
sqlite-connector = ["sqlite", "rusqlite/bundled", "tokio/sync"]
sqlite-native = ["sqlite", "rusqlite/bundled", "tokio/sync"]
sqlite = ["rusqlite"]

fmt-sql = ["sqlformat"]
Expand Down
8 changes: 4 additions & 4 deletions quaint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ Quaint is an abstraction over certain SQL databases. It provides:
### Feature flags

- `mysql`: Support for MySQL databases.
- On non-WebAssembly targets, choose `mysql-connector` instead.
- On non-WebAssembly targets, choose `mysql-native` instead.
- `postgresql`: Support for PostgreSQL databases.
- On non-WebAssembly targets, choose `postgresql-connector` instead.
- On non-WebAssembly targets, choose `postgresql-native` instead.
- `sqlite`: Support for SQLite databases.
- On non-WebAssembly targets, choose `sqlite-connector` instead.
- On non-WebAssembly targets, choose `sqlite-native` instead.
- `mssql`: Support for Microsoft SQL Server databases.
- On non-WebAssembly targets, choose `mssql-connector` instead.
- On non-WebAssembly targets, choose `mssql-native` instead.
- `pooled`: A connection pool in `pooled::Quaint`.
- `vendored-openssl`: Statically links against a vendored OpenSSL library on
non-Windows or non-Apple platforms.
Expand Down
20 changes: 6 additions & 14 deletions quaint/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ mod connection_info;
pub mod metrics;
mod queryable;
mod result_set;
#[cfg(any(
feature = "mssql-connector",
feature = "postgresql-connector",
feature = "mysql-connector"
))]
#[cfg(any(feature = "mssql-native", feature = "postgresql-native", feature = "mysql-native"))]
mod timeout;
mod transaction;
mod type_identifier;
Expand All @@ -27,40 +23,36 @@ pub use self::result_set::*;
pub use connection_info::*;
pub use queryable::*;
pub use transaction::*;
#[cfg(any(
feature = "mssql-connector",
feature = "postgresql-connector",
feature = "mysql-connector"
))]
#[cfg(any(feature = "mssql-native", feature = "postgresql-native", feature = "mysql-native"))]
#[allow(unused_imports)]
pub(crate) use type_identifier::*;

pub use self::metrics::query;

#[cfg(feature = "postgresql")]
pub(crate) mod postgres;
#[cfg(feature = "postgresql-connector")]
#[cfg(feature = "postgresql-native")]
pub use postgres::native::*;
#[cfg(feature = "postgresql")]
pub use postgres::wasm::common::*;

#[cfg(feature = "mysql")]
pub(crate) mod mysql;
#[cfg(feature = "mysql-connector")]
#[cfg(feature = "mysql-native")]
pub use mysql::native::*;
#[cfg(feature = "mysql")]
pub use mysql::wasm::common::*;

#[cfg(feature = "sqlite")]
pub(crate) mod sqlite;
#[cfg(feature = "sqlite-connector")]
#[cfg(feature = "sqlite-native")]
pub use sqlite::native::*;
#[cfg(feature = "sqlite")]
pub use sqlite::wasm::common::*;

#[cfg(feature = "mssql")]
pub(crate) mod mssql;
#[cfg(feature = "mssql-connector")]
#[cfg(feature = "mssql-native")]
pub use mssql::native::*;
#[cfg(feature = "mssql")]
pub use mssql::wasm::common::*;
2 changes: 1 addition & 1 deletion quaint/src/connector/mssql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pub use wasm::common::MssqlUrl;
#[cfg(feature = "mssql")]
pub(crate) mod wasm;

#[cfg(feature = "mssql-connector")]
#[cfg(feature = "mssql-native")]
pub(crate) mod native;
2 changes: 1 addition & 1 deletion quaint/src/connector/mssql/native/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Definitions for the MSSQL connector.
//! This module is not compatible with wasm32-* targets.
//! This module is only available with the `mssql-connector` feature.
//! This module is only available with the `mssql-native` feature.
mod conversion;
mod error;

Expand Down
2 changes: 1 addition & 1 deletion quaint/src/connector/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ pub use wasm::error::MysqlError;
#[cfg(feature = "mysql")]
pub(crate) mod wasm;

#[cfg(feature = "mysql-connector")]
#[cfg(feature = "mysql-native")]
pub(crate) mod native;
2 changes: 1 addition & 1 deletion quaint/src/connector/mysql/native/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Definitions for the MySQL connector.
//! This module is not compatible with wasm32-* targets.
//! This module is only available with the `mysql-connector` feature.
//! This module is only available with the `mysql-native` feature.
mod conversion;
mod error;

Expand Down
12 changes: 6 additions & 6 deletions quaint/src/connector/mysql/wasm/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl MysqlUrl {
}

fn parse_query_params(url: &Url) -> Result<MysqlUrlQueryParams, Error> {
#[cfg(feature = "mysql-connector")]
#[cfg(feature = "mysql-native")]
let mut ssl_opts = {
let mut ssl_opts = mysql_async::SslOpts::default();
ssl_opts = ssl_opts.with_danger_accept_invalid_certs(true);
Expand Down Expand Up @@ -159,7 +159,7 @@ impl MysqlUrl {
"sslcert" => {
use_ssl = true;

#[cfg(feature = "mysql-connector")]
#[cfg(feature = "mysql-native")]
{
ssl_opts = ssl_opts.with_root_cert_path(Some(Path::new(&*v).to_path_buf()));
}
Expand Down Expand Up @@ -219,7 +219,7 @@ impl MysqlUrl {
use_ssl = true;
match v.as_ref() {
"strict" => {
#[cfg(feature = "mysql-connector")]
#[cfg(feature = "mysql-native")]
{
ssl_opts = ssl_opts.with_danger_accept_invalid_certs(false);
}
Expand Down Expand Up @@ -263,7 +263,7 @@ impl MysqlUrl {

// Wrapping this in a block, as attributes on expressions are still experimental
// See: https://github.com/rust-lang/rust/issues/15701
#[cfg(feature = "mysql-connector")]
#[cfg(feature = "mysql-native")]
{
ssl_opts = match identity {
Some((Some(path), Some(pw))) => {
Expand All @@ -279,7 +279,7 @@ impl MysqlUrl {
}

Ok(MysqlUrlQueryParams {
#[cfg(feature = "mysql-connector")]
#[cfg(feature = "mysql-native")]
ssl_opts,
connection_limit,
use_ssl,
Expand Down Expand Up @@ -313,6 +313,6 @@ pub(crate) struct MysqlUrlQueryParams {
pub(crate) prefer_socket: Option<bool>,
pub(crate) statement_cache_size: usize,

#[cfg(feature = "mysql-connector")]
#[cfg(feature = "mysql-native")]
pub(crate) ssl_opts: mysql_async::SslOpts,
}
2 changes: 1 addition & 1 deletion quaint/src/connector/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ pub use wasm::error::PostgresError;
#[cfg(feature = "postgresql")]
pub(crate) mod wasm;

#[cfg(feature = "postgresql-connector")]
#[cfg(feature = "postgresql-native")]
pub(crate) mod native;
2 changes: 1 addition & 1 deletion quaint/src/connector/postgres/native/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Definitions for the Postgres connector.
//! This module is not compatible with wasm32-* targets.
//! This module is only available with the `postgresql-connector` feature.
//! This module is only available with the `postgresql-native` feature.
mod conversion;
mod error;

Expand Down
18 changes: 9 additions & 9 deletions quaint/src/connector/postgres/wasm/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use url::{Host, Url};

use crate::error::{Error, ErrorKind};

#[cfg(feature = "postgresql-connector")]
#[cfg(feature = "postgresql-native")]
use tokio_postgres::config::{ChannelBinding, SslMode};

#[derive(Clone)]
Expand Down Expand Up @@ -211,9 +211,9 @@ impl PostgresUrl {
}

fn parse_query_params(url: &Url) -> Result<PostgresUrlQueryParams, Error> {
#[cfg(feature = "postgresql-connector")]
#[cfg(feature = "postgresql-native")]
let mut ssl_mode = SslMode::Prefer;
#[cfg(feature = "postgresql-connector")]
#[cfg(feature = "postgresql-native")]
let mut channel_binding = ChannelBinding::Prefer;

let mut connection_limit = None;
Expand All @@ -240,7 +240,7 @@ impl PostgresUrl {
.parse()
.map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?;
}
#[cfg(feature = "postgresql-connector")]
#[cfg(feature = "postgresql-native")]
"sslmode" => {
match v.as_ref() {
"disable" => ssl_mode = SslMode::Disable,
Expand Down Expand Up @@ -348,7 +348,7 @@ impl PostgresUrl {
"application_name" => {
application_name = Some(v.to_string());
}
#[cfg(feature = "postgresql-connector")]
#[cfg(feature = "postgresql-native")]
"channel_binding" => {
match v.as_ref() {
"disable" => channel_binding = ChannelBinding::Disable,
Expand Down Expand Up @@ -390,9 +390,9 @@ impl PostgresUrl {
max_idle_connection_lifetime,
application_name,
options,
#[cfg(feature = "postgresql-connector")]
#[cfg(feature = "postgresql-native")]
channel_binding,
#[cfg(feature = "postgresql-connector")]
#[cfg(feature = "postgresql-native")]
ssl_mode,
})
}
Expand Down Expand Up @@ -427,10 +427,10 @@ pub(crate) struct PostgresUrlQueryParams {
pub(crate) application_name: Option<String>,
pub(crate) options: Option<String>,

#[cfg(feature = "postgresql-connector")]
#[cfg(feature = "postgresql-native")]
pub(crate) channel_binding: ChannelBinding,

#[cfg(feature = "postgresql-connector")]
#[cfg(feature = "postgresql-native")]
pub(crate) ssl_mode: SslMode,
}

Expand Down
2 changes: 1 addition & 1 deletion quaint/src/connector/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pub use wasm::error::SqliteError;
#[cfg(feature = "sqlite")]
pub(crate) mod wasm;

#[cfg(feature = "sqlite-connector")]
#[cfg(feature = "sqlite-native")]
pub(crate) mod native;
2 changes: 1 addition & 1 deletion quaint/src/connector/sqlite/native/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Definitions for the SQLite connector.
//! This module is not compatible with wasm32-* targets.
//! This module is only available with the `sqlite-connector` feature.
//! This module is only available with the `sqlite-native` feature.
mod conversion;
mod error;

Expand Down
2 changes: 1 addition & 1 deletion quaint/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ pub enum ErrorKind {
}

impl ErrorKind {
#[cfg(feature = "mysql-connector")]
#[cfg(feature = "mysql-native")]
pub(crate) fn value_out_of_range(msg: impl Into<String>) -> Self {
Self::ValueOutOfRange { message: msg.into() }
}
Expand Down
Loading

0 comments on commit 257c4c8

Please sign in to comment.