Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitff7d88f

Browse files
authored
Merge pull request#783 from timando/master
Add support for eui48 version 1.0
2 parents0c064a9 +a8383dc commitff7d88f

File tree

9 files changed

+58
-2
lines changed

9 files changed

+58
-2
lines changed

‎postgres-types/Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ derive = ["postgres-derive"]
1515
with-bit-vec-0_6 = ["bit-vec-06"]
1616
with-chrono-0_4 = ["chrono-04"]
1717
with-eui48-0_4 = ["eui48-04"]
18+
with-eui48-1 = ["eui48-1"]
1819
with-geo-types-0_6 = ["geo-types-06"]
1920
with-geo-types-0_7 = ["geo-types-0_7"]
2021
with-serde_json-1 = ["serde-1","serde_json-1"]
@@ -30,6 +31,7 @@ postgres-derive = { version = "0.4.0", optional = true, path = "../postgres-deri
3031
bit-vec-06 = {version ="0.6",package ="bit-vec",optional =true }
3132
chrono-04 = {version ="0.4.16",package ="chrono",default-features =false,features = ["clock"],optional =true }
3233
eui48-04 = {version ="0.4",package ="eui48",optional =true }
34+
eui48-1 = {version ="1.0",package ="eui48",optional =true }
3335
geo-types-06 = {version ="0.6",package ="geo-types",optional =true }
3436
geo-types-0_7 = {version ="0.7",package ="geo-types",optional =true }
3537
serde-1 = {version ="1.0",package ="serde",optional =true }

‎postgres-types/src/eui48_1.rs‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use bytes::BytesMut;
2+
use eui48_1::MacAddress;
3+
use postgres_protocol::types;
4+
use std::error::Error;
5+
6+
usecrate::{FromSql,IsNull,ToSql,Type};
7+
8+
impl<'a>FromSql<'a>forMacAddress{
9+
fnfrom_sql(_:&Type,raw:&[u8]) ->Result<MacAddress,Box<dynError +Sync +Send>>{
10+
let bytes = types::macaddr_from_sql(raw)?;
11+
Ok(MacAddress::new(bytes))
12+
}
13+
14+
accepts!(MACADDR);
15+
}
16+
17+
implToSqlforMacAddress{
18+
fnto_sql(&self, _:&Type,w:&mutBytesMut) ->Result<IsNull,Box<dynError +Sync +Send>>{
19+
letmut bytes =[0;6];
20+
bytes.copy_from_slice(self.as_bytes());
21+
types::macaddr_to_sql(bytes, w);
22+
Ok(IsNull::No)
23+
}
24+
25+
accepts!(MACADDR);
26+
to_sql_checked!();
27+
}

‎postgres-types/src/lib.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ mod bit_vec_06;
194194
mod chrono_04;
195195
#[cfg(feature ="with-eui48-0_4")]
196196
mod eui48_04;
197+
#[cfg(feature ="with-eui48-1")]
198+
mod eui48_1;
197199
#[cfg(feature ="with-geo-types-0_6")]
198200
mod geo_types_06;
199201
#[cfg(feature ="with-geo-types-0_7")]

‎postgres/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ circle-ci = { repository = "sfackler/rust-postgres" }
2424
with-bit-vec-0_6 = ["tokio-postgres/with-bit-vec-0_6"]
2525
with-chrono-0_4 = ["tokio-postgres/with-chrono-0_4"]
2626
with-eui48-0_4 = ["tokio-postgres/with-eui48-0_4"]
27+
with-eui48-1 = ["tokio-postgres/with-eui48-1"]
2728
with-geo-types-0_6 = ["tokio-postgres/with-geo-types-0_6"]
2829
with-geo-types-0_7 = ["tokio-postgres/with-geo-types-0_7"]
2930
with-serde_json-1 = ["tokio-postgres/with-serde_json-1"]

‎postgres/src/lib.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
//! | ------- | ----------- | ------------------ | ------- |
5656
//! | `with-bit-vec-0_6` | Enable support for the `bit-vec` crate. | [bit-vec](https://crates.io/crates/bit-vec) 0.6 | no |
5757
//! | `with-chrono-0_4` | Enable support for the `chrono` crate. | [chrono](https://crates.io/crates/chrono) 0.4 | no |
58-
//! | `with-eui48-0_4` | Enable support for the `eui48` crate. | [eui48](https://crates.io/crates/eui48) 0.4 | no |
58+
//! | `with-eui48-0_4` | Enable support for the 0.4 version of the `eui48` crate. | [eui48](https://crates.io/crates/eui48) 0.4 | no |
59+
//! | `with-eui48-1` | Enable support for the 1.0 version of the `eui48` crate. | [eui48](https://crates.io/crates/eui48) 1.0 | no |
5960
//! | `with-geo-types-0_6` | Enable support for the 0.6 version of the `geo-types` crate. | [geo-types](https://crates.io/crates/geo-types/0.6.0) 0.6 | no |
6061
//! | `with-geo-types-0_7` | Enable support for the 0.7 version of the `geo-types` crate. | [geo-types](https://crates.io/crates/geo-types/0.7.0) 0.7 | no |
6162
//! | `with-serde_json-1` | Enable support for the `serde_json` crate. | [serde_json](https://crates.io/crates/serde_json) 1.0 | no |

‎tokio-postgres/Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ runtime = ["tokio/net", "tokio/time"]
3030
with-bit-vec-0_6 = ["postgres-types/with-bit-vec-0_6"]
3131
with-chrono-0_4 = ["postgres-types/with-chrono-0_4"]
3232
with-eui48-0_4 = ["postgres-types/with-eui48-0_4"]
33+
with-eui48-1 = ["postgres-types/with-eui48-1"]
3334
with-geo-types-0_6 = ["postgres-types/with-geo-types-0_6"]
3435
with-geo-types-0_7 = ["postgres-types/with-geo-types-0_7"]
3536
with-serde_json-1 = ["postgres-types/with-serde_json-1"]
@@ -61,6 +62,7 @@ criterion = "0.3"
6162
bit-vec-06 = {version ="0.6",package ="bit-vec" }
6263
chrono-04 = {version ="0.4",package ="chrono",default-features =false }
6364
eui48-04 = {version ="0.4",package ="eui48" }
65+
eui48-1 = {version ="1.0",package ="eui48" }
6466
geo-types-06 = {version ="0.6",package ="geo-types" }
6567
geo-types-07 = {version ="0.7",package ="geo-types" }
6668
serde-1 = {version ="1.0",package ="serde" }

‎tokio-postgres/src/lib.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@
106106
//! | `runtime` | Enable convenience API for the connection process based on the `tokio` crate. | [tokio](https://crates.io/crates/tokio) 1.0 with the features `net` and `time` | yes |
107107
//! | `with-bit-vec-0_6` | Enable support for the `bit-vec` crate. | [bit-vec](https://crates.io/crates/bit-vec) 0.6 | no |
108108
//! | `with-chrono-0_4` | Enable support for the `chrono` crate. | [chrono](https://crates.io/crates/chrono) 0.4 | no |
109-
//! | `with-eui48-0_4` | Enable support for the `eui48` crate. | [eui48](https://crates.io/crates/eui48) 0.4 | no |
109+
//! | `with-eui48-0_4` | Enable support for the 0.4 version of the `eui48` crate. | [eui48](https://crates.io/crates/eui48) 0.4 | no |
110+
//! | `with-eui48-1` | Enable support for the 1.0 version of the `eui48` crate. | [eui48](https://crates.io/crates/eui48) 1.0 | no |
110111
//! | `with-geo-types-0_6` | Enable support for the 0.6 version of the `geo-types` crate. | [geo-types](https://crates.io/crates/geo-types/0.6.0) 0.6 | no |
111112
//! | `with-geo-types-0_7` | Enable support for the 0.7 version of the `geo-types` crate. | [geo-types](https://crates.io/crates/geo-types/0.7.0) 0.7 | no |
112113
//! | `with-serde_json-1` | Enable support for the `serde_json` crate. | [serde_json](https://crates.io/crates/serde_json) 1.0 | no |
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use eui48_1::MacAddress;
2+
3+
usecrate::types::test_type;
4+
5+
#[tokio::test]
6+
asyncfntest_eui48_params(){
7+
test_type(
8+
"MACADDR",
9+
&[
10+
(
11+
Some(MacAddress::parse_str("12-34-56-AB-CD-EF").unwrap()),
12+
"'12-34-56-ab-cd-ef'",
13+
),
14+
(None,"NULL"),
15+
],
16+
)
17+
.await
18+
}

‎tokio-postgres/tests/test/types/mod.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ mod bit_vec_06;
1919
mod chrono_04;
2020
#[cfg(feature ="with-eui48-0_4")]
2121
mod eui48_04;
22+
#[cfg(feature ="with-eui48-1")]
23+
mod eui48_1;
2224
#[cfg(feature ="with-geo-types-0_6")]
2325
mod geo_types_06;
2426
#[cfg(feature ="with-geo-types-0_7")]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp