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