Document cidr type conversion and run rustfmt
This commit is contained in:
@@ -33,8 +33,8 @@ postgres-derive = { version = "0.4.0", optional = true, path = "../postgres-deri
|
||||
|
||||
array-init = { version = "2", optional = true }
|
||||
bit-vec-06 = { version = "0.6", package = "bit-vec", optional = true }
|
||||
cidr-02 = { version = "0.2", package = "cidr", optional = true }
|
||||
chrono-04 = { version = "0.4.16", package = "chrono", default-features = false, features = ["clock"], optional = true }
|
||||
cidr-02 = { version = "0.2", package = "cidr", optional = true }
|
||||
eui48-04 = { version = "0.4", package = "eui48", optional = true }
|
||||
eui48-1 = { version = "1.0", package = "eui48", optional = true }
|
||||
geo-types-06 = { version = "0.6", package = "geo-types", optional = true }
|
||||
|
||||
@@ -8,7 +8,8 @@ use crate::{FromSql, IsNull, ToSql, Type};
|
||||
impl<'a> FromSql<'a> for IpCidr {
|
||||
fn from_sql(_: &Type, raw: &[u8]) -> Result<Self, Box<dyn Error + Sync + Send>> {
|
||||
let inet = types::inet_from_sql(raw)?;
|
||||
Ok(IpCidr::new(inet.addr(), inet.netmask()).expect("postgres cidr type has zeroed host portion"))
|
||||
Ok(IpCidr::new(inet.addr(), inet.netmask())
|
||||
.expect("postgres cidr type has zeroed host portion"))
|
||||
}
|
||||
|
||||
accepts!(CIDR);
|
||||
@@ -27,7 +28,8 @@ impl ToSql for IpCidr {
|
||||
impl<'a> FromSql<'a> for IpInet {
|
||||
fn from_sql(_: &Type, raw: &[u8]) -> Result<Self, Box<dyn Error + Sync + Send>> {
|
||||
let inet = types::inet_from_sql(raw)?;
|
||||
Ok(IpInet::new(inet.addr(), inet.netmask()).expect("postgres enforces maximum length of netmask"))
|
||||
Ok(IpInet::new(inet.addr(), inet.netmask())
|
||||
.expect("postgres enforces maximum length of netmask"))
|
||||
}
|
||||
|
||||
accepts!(INET);
|
||||
|
||||
@@ -210,10 +210,10 @@ where
|
||||
|
||||
#[cfg(feature = "with-bit-vec-0_6")]
|
||||
mod bit_vec_06;
|
||||
#[cfg(feature = "with-cidr-0_2")]
|
||||
mod cidr_02;
|
||||
#[cfg(feature = "with-chrono-0_4")]
|
||||
mod chrono_04;
|
||||
#[cfg(feature = "with-cidr-0_2")]
|
||||
mod cidr_02;
|
||||
#[cfg(feature = "with-eui48-0_4")]
|
||||
mod eui48_04;
|
||||
#[cfg(feature = "with-eui48-1")]
|
||||
@@ -438,6 +438,8 @@ impl WrongType {
|
||||
/// | `uuid::Uuid` | UUID |
|
||||
/// | `bit_vec::BitVec` | BIT, VARBIT |
|
||||
/// | `eui48::MacAddress` | MACADDR |
|
||||
/// | `cidr::InetCidr` | CIDR |
|
||||
/// | `cidr::InetAddr` | INET |
|
||||
///
|
||||
/// # Nullability
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user