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

Add support for eui48 version 1.0#783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sfackler merged 1 commit intorust-postgres:masterfromtimando:master
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletionspostgres-types/Cargo.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@ derive = ["postgres-derive"]
with-bit-vec-0_6 = ["bit-vec-06"]
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"]
Expand All@@ -30,6 +31,7 @@ postgres-derive = { version = "0.4.0", optional = true, path = "../postgres-deri
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 }
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 }
Expand Down
27 changes: 27 additions & 0 deletionspostgres-types/src/eui48_1.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
use bytes::BytesMut;
use eui48_1::MacAddress;
use postgres_protocol::types;
use std::error::Error;

use crate::{FromSql, IsNull, ToSql, Type};

impl<'a> FromSql<'a> for MacAddress {
fn from_sql(_: &Type, raw: &[u8]) -> Result<MacAddress, Box<dyn Error + Sync + Send>> {
let bytes = types::macaddr_from_sql(raw)?;
Ok(MacAddress::new(bytes))
}

accepts!(MACADDR);
}

impl ToSql for MacAddress {
fn to_sql(&self, _: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
let mut bytes = [0; 6];
bytes.copy_from_slice(self.as_bytes());
types::macaddr_to_sql(bytes, w);
Ok(IsNull::No)
}

accepts!(MACADDR);
to_sql_checked!();
}
2 changes: 2 additions & 0 deletionspostgres-types/src/lib.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -194,6 +194,8 @@ mod bit_vec_06;
mod chrono_04;
#[cfg(feature = "with-eui48-0_4")]
mod eui48_04;
#[cfg(feature = "with-eui48-1")]
mod eui48_1;
#[cfg(feature = "with-geo-types-0_6")]
mod geo_types_06;
#[cfg(feature = "with-geo-types-0_7")]
Expand Down
1 change: 1 addition & 0 deletionspostgres/Cargo.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,7 @@ circle-ci = { repository = "sfackler/rust-postgres" }
with-bit-vec-0_6 = ["tokio-postgres/with-bit-vec-0_6"]
with-chrono-0_4 = ["tokio-postgres/with-chrono-0_4"]
with-eui48-0_4 = ["tokio-postgres/with-eui48-0_4"]
with-eui48-1 = ["tokio-postgres/with-eui48-1"]
with-geo-types-0_6 = ["tokio-postgres/with-geo-types-0_6"]
with-geo-types-0_7 = ["tokio-postgres/with-geo-types-0_7"]
with-serde_json-1 = ["tokio-postgres/with-serde_json-1"]
Expand Down
3 changes: 2 additions & 1 deletionpostgres/src/lib.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,8 @@
//! | ------- | ----------- | ------------------ | ------- |
//! | `with-bit-vec-0_6` | Enable support for the `bit-vec` crate. | [bit-vec](https://crates.io/crates/bit-vec) 0.6 | no |
//! | `with-chrono-0_4` | Enable support for the `chrono` crate. | [chrono](https://crates.io/crates/chrono) 0.4 | no |
//! | `with-eui48-0_4` | Enable support for the `eui48` crate. | [eui48](https://crates.io/crates/eui48) 0.4 | no |
//! | `with-eui48-0_4` | Enable support for the 0.4 version of the `eui48` crate. | [eui48](https://crates.io/crates/eui48) 0.4 | no |
//! | `with-eui48-1` | Enable support for the 1.0 version of the `eui48` crate. | [eui48](https://crates.io/crates/eui48) 1.0 | no |
//! | `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 |
//! | `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 |
//! | `with-serde_json-1` | Enable support for the `serde_json` crate. | [serde_json](https://crates.io/crates/serde_json) 1.0 | no |
Expand Down
2 changes: 2 additions & 0 deletionstokio-postgres/Cargo.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,7 @@ runtime = ["tokio/net", "tokio/time"]
with-bit-vec-0_6 = ["postgres-types/with-bit-vec-0_6"]
with-chrono-0_4 = ["postgres-types/with-chrono-0_4"]
with-eui48-0_4 = ["postgres-types/with-eui48-0_4"]
with-eui48-1 = ["postgres-types/with-eui48-1"]
with-geo-types-0_6 = ["postgres-types/with-geo-types-0_6"]
with-geo-types-0_7 = ["postgres-types/with-geo-types-0_7"]
with-serde_json-1 = ["postgres-types/with-serde_json-1"]
Expand DownExpand Up@@ -61,6 +62,7 @@ criterion = "0.3"
bit-vec-06 = { version = "0.6", package = "bit-vec" }
chrono-04 = { version = "0.4", package = "chrono", default-features = false }
eui48-04 = { version = "0.4", package = "eui48" }
eui48-1 = { version = "1.0", package = "eui48" }
geo-types-06 = { version = "0.6", package = "geo-types" }
geo-types-07 = { version = "0.7", package = "geo-types" }
serde-1 = { version = "1.0", package = "serde" }
Expand Down
3 changes: 2 additions & 1 deletiontokio-postgres/src/lib.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -106,7 +106,8 @@
//! | `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 |
//! | `with-bit-vec-0_6` | Enable support for the `bit-vec` crate. | [bit-vec](https://crates.io/crates/bit-vec) 0.6 | no |
//! | `with-chrono-0_4` | Enable support for the `chrono` crate. | [chrono](https://crates.io/crates/chrono) 0.4 | no |
//! | `with-eui48-0_4` | Enable support for the `eui48` crate. | [eui48](https://crates.io/crates/eui48) 0.4 | no |
//! | `with-eui48-0_4` | Enable support for the 0.4 version of the `eui48` crate. | [eui48](https://crates.io/crates/eui48) 0.4 | no |
//! | `with-eui48-1` | Enable support for the 1.0 version of the `eui48` crate. | [eui48](https://crates.io/crates/eui48) 1.0 | no |
//! | `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 |
//! | `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 |
//! | `with-serde_json-1` | Enable support for the `serde_json` crate. | [serde_json](https://crates.io/crates/serde_json) 1.0 | no |
Expand Down
18 changes: 18 additions & 0 deletionstokio-postgres/tests/test/types/eui48_1.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
use eui48_1::MacAddress;

use crate::types::test_type;

#[tokio::test]
async fn test_eui48_params() {
test_type(
"MACADDR",
&[
(
Some(MacAddress::parse_str("12-34-56-AB-CD-EF").unwrap()),
"'12-34-56-ab-cd-ef'",
),
(None, "NULL"),
],
)
.await
}
2 changes: 2 additions & 0 deletionstokio-postgres/tests/test/types/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,8 @@ mod bit_vec_06;
mod chrono_04;
#[cfg(feature = "with-eui48-0_4")]
mod eui48_04;
#[cfg(feature = "with-eui48-1")]
mod eui48_1;
#[cfg(feature = "with-geo-types-0_6")]
mod geo_types_06;
#[cfg(feature = "with-geo-types-0_7")]
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp