mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-02 15:25:32 +00:00
rename feature gate to ipnetwork
This commit is contained in:
parent
060c5d2b66
commit
c9cca27e65
@ -48,6 +48,7 @@ sqlite = [ "sqlx-core/sqlite", "sqlx-macros/sqlite" ]
|
||||
# types
|
||||
bigdecimal = ["sqlx-core/bigdecimal_bigint", "sqlx-macros/bigdecimal"]
|
||||
chrono = [ "sqlx-core/chrono", "sqlx-macros/chrono" ]
|
||||
ipnetwork = [ "sqlx-core/ipnetwork", "sqlx-macros/ipnetwork" ]
|
||||
uuid = [ "sqlx-core/uuid", "sqlx-macros/uuid" ]
|
||||
|
||||
[dependencies]
|
||||
|
@ -18,7 +18,6 @@ unstable = []
|
||||
# we need a feature which activates `num-bigint` as well because
|
||||
# `bigdecimal` uses types from it but does not reexport (tsk tsk)
|
||||
bigdecimal_bigint = ["bigdecimal", "num-bigint"]
|
||||
network-address = [ "ipnetwork", "libc" ]
|
||||
postgres = [ "md-5", "sha2", "base64", "sha-1", "rand", "hmac", "futures-channel/sink", "futures-util/sink" ]
|
||||
mysql = [ "sha-1", "sha2", "generic-array", "num-bigint", "base64", "digest", "rand" ]
|
||||
sqlite = [ "libsqlite3-sys" ]
|
||||
@ -45,7 +44,7 @@ generic-array = { version = "0.12.3", default-features = false, optional = true
|
||||
hex = "0.4.2"
|
||||
hmac = { version = "0.7.1", default-features = false, optional = true }
|
||||
ipnetwork = { version = "0.16.0", default-feature = false, optional = true }
|
||||
libc = { version = "0.2.68", default-feature = false, optional = true }
|
||||
libc = "0.2.68"
|
||||
log = { version = "0.4.8", default-features = false }
|
||||
md-5 = { version = "0.8.0", default-features = false, optional = true }
|
||||
memchr = { version = "2.3.3", default-features = false }
|
||||
|
@ -55,7 +55,7 @@ impl<'de> Decode<'de, Postgres> for IpNetwork {
|
||||
fn decode(value: Option<PgValue<'de>>) -> crate::Result<Self> {
|
||||
match value.try_into()? {
|
||||
PgValue::Binary(buf) => decode(buf, INET_TYPE),
|
||||
PgValue::Text(s) => decode(s.as_bytes(), INET_TYPE),
|
||||
PgValue::Text(s) => s.parse().map_err(|err| crate::Error::decode(err)),
|
||||
}
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@
|
||||
//!
|
||||
//! ### [`ipnetwork`](https://crates.io/crates/ipnetwork)
|
||||
//!
|
||||
//! Requires the `network-address` Cargo feature flag.
|
||||
//! Requires the `ipnetwork` Cargo feature flag.
|
||||
//!
|
||||
//! | Rust type | Postgres type(s) |
|
||||
//! |---------------------------------------|------------------------------------------------------|
|
||||
@ -78,7 +78,8 @@ mod chrono;
|
||||
#[cfg(feature = "uuid")]
|
||||
mod uuid;
|
||||
|
||||
mod network;
|
||||
#[cfg(feature = "ipnetwork")]
|
||||
mod ipnetwork;
|
||||
|
||||
/// Type information for a Postgres SQL type.
|
||||
#[derive(Debug, Clone)]
|
||||
@ -118,6 +119,7 @@ impl PgTypeInfo {
|
||||
TypeId::UUID => Some("uuid"),
|
||||
// we can support decoding `PgNumeric` but it's decidedly less useful to the layman
|
||||
TypeId::NUMERIC => Some("bigdecimal"),
|
||||
TypeId::CIDR | TypeId::INET => Some("ipnetwork"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,12 @@ pub mod chrono {
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "bigdecimal")))]
|
||||
pub use bigdecimal::BigDecimal;
|
||||
|
||||
#[cfg(feature = "ipnetwork")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "ipnetwork")))]
|
||||
pub mod ipnetwork {
|
||||
pub use ipnetwork::{IpNetwork, Ipv4Network, Ipv6Network};
|
||||
}
|
||||
|
||||
pub trait TypeInfo: Debug + Display + Clone {
|
||||
/// Compares type information to determine if `other` is compatible at the Rust level
|
||||
/// with `self`.
|
||||
|
@ -29,6 +29,7 @@ sqlite = [ "sqlx/sqlite" ]
|
||||
# type
|
||||
bigdecimal = [ "sqlx/bigdecimal_bigint" ]
|
||||
chrono = [ "sqlx/chrono" ]
|
||||
ipnetwork = [ "sqlx/ipnetwork" ]
|
||||
uuid = [ "sqlx/uuid" ]
|
||||
|
||||
[dependencies]
|
||||
|
@ -27,7 +27,10 @@ impl_database_ext! {
|
||||
sqlx::types::chrono::DateTime<sqlx::types::chrono::Utc> | sqlx::types::chrono::DateTime<_>,
|
||||
|
||||
#[cfg(feature = "bigdecimal")]
|
||||
sqlx::types::BigDecimal
|
||||
sqlx::types::BigDecimal,
|
||||
|
||||
#[cfg(feature = "ipnetwork")]
|
||||
sqlx::types::ipnetwork::IpNetwork
|
||||
},
|
||||
ParamChecking::Strong,
|
||||
feature-types: info => info.type_feature_gate(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user