forked from sfackler/rust-postgres
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'sfackler/master'
- Loading branch information
Showing
22 changed files
with
428 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "postgres-derive" | ||
version = "0.4.1" | ||
version = "0.4.2" | ||
authors = ["Steven Fackler <[email protected]>"] | ||
license = "MIT/Apache-2.0" | ||
edition = "2018" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "postgres-protocol" | ||
version = "0.6.3" | ||
version = "0.6.4" | ||
authors = ["Steven Fackler <[email protected]>"] | ||
edition = "2018" | ||
description = "Low level Postgres protocol APIs" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "postgres-types" | ||
version = "0.2.2" | ||
version = "0.2.3" | ||
authors = ["Steven Fackler <[email protected]>"] | ||
edition = "2018" | ||
license = "MIT/Apache-2.0" | ||
|
@@ -14,31 +14,37 @@ categories = ["database"] | |
derive = ["postgres-derive"] | ||
array-impls = ["array-init"] | ||
with-bit-vec-0_6 = ["bit-vec-06"] | ||
with-cidr-0_2 = ["cidr-02"] | ||
with-chrono-0_4 = ["chrono-04"] | ||
with-eui48-0_4 = ["eui48-04"] | ||
with-eui48-1 = ["eui48-1"] | ||
with-geo-types-0_6 = ["geo-types-06"] | ||
with-geo-types-0_7 = ["geo-types-0_7"] | ||
with-serde_json-1 = ["serde-1", "serde_json-1"] | ||
with-uuid-0_8 = ["uuid-08"] | ||
with-uuid-1 = ["uuid-1"] | ||
with-time-0_2 = ["time-02"] | ||
with-time-0_3 = ["time-03"] | ||
|
||
[dependencies] | ||
bytes = "1.0" | ||
fallible-iterator = "0.2" | ||
postgres-protocol = { version = "0.6.1", path = "../postgres-protocol" } | ||
postgres-derive = { version = "0.4.0", optional = true, path = "../postgres-derive" } | ||
postgres-protocol = { version = "0.6.4", path = "../postgres-protocol" } | ||
postgres-derive = { version = "0.4.2", optional = true, path = "../postgres-derive" } | ||
|
||
array-init = { version = "2", optional = true } | ||
bit-vec-06 = { version = "0.6", package = "bit-vec", optional = true } | ||
chrono-04 = { version = "0.4.16", package = "chrono", default-features = false, features = ["clock"], 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 } | ||
geo-types-0_7 = { version = "0.7", package = "geo-types", optional = true } | ||
serde-1 = { version = "1.0", package = "serde", optional = true } | ||
serde_json-1 = { version = "1.0", package = "serde_json", optional = true } | ||
uuid-08 = { version = "0.8", package = "uuid", optional = true } | ||
uuid-1 = { version = "1.0", package = "uuid", optional = true } | ||
time-02 = { version = "0.2", package = "time", optional = true } | ||
time-03 = { version = "0.3", package = "time", default-features = false, optional = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use bytes::BytesMut; | ||
use cidr_02::{IpCidr, IpInet}; | ||
use postgres_protocol::types; | ||
use std::error::Error; | ||
|
||
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())?) | ||
} | ||
|
||
accepts!(CIDR); | ||
} | ||
|
||
impl ToSql for IpCidr { | ||
fn to_sql(&self, _: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> { | ||
types::inet_to_sql(self.first_address(), self.network_length(), w); | ||
Ok(IsNull::No) | ||
} | ||
|
||
accepts!(CIDR); | ||
to_sql_checked!(); | ||
} | ||
|
||
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())?) | ||
} | ||
|
||
accepts!(INET); | ||
} | ||
|
||
impl ToSql for IpInet { | ||
fn to_sql(&self, _: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> { | ||
types::inet_to_sql(self.address(), self.network_length(), w); | ||
Ok(IsNull::No) | ||
} | ||
|
||
accepts!(INET); | ||
to_sql_checked!(); | ||
} |
Oops, something went wrong.