mirror of
https://github.com/achanda/ipnetwork.git
synced 2025-06-16 08:48:51 +00:00
Remove with-serde in favor of just 'serde'
https://rust-lang-nursery.github.io/api-guidelines/naming.html#feature-names-are-free-of-placeholder-words-c-feature
This commit is contained in:
@ -11,7 +11,7 @@ env:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- rust: nightly
|
- rust: nightly
|
||||||
env: FEATURES=ipv6-iterator,ipv6-methods,with-serde
|
env: FEATURES=ipv6-iterator,ipv6-methods,serde,serde-derive
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cargo build --features $FEATURES --verbose
|
- cargo build --features $FEATURES --verbose
|
||||||
|
@ -26,4 +26,3 @@ default = []
|
|||||||
dev = ["clippy"]
|
dev = ["clippy"]
|
||||||
ipv6-iterator = []
|
ipv6-iterator = []
|
||||||
ipv6-methods = []
|
ipv6-methods = []
|
||||||
with-serde = ["serde", "serde_derive"]
|
|
||||||
|
@ -2,7 +2,7 @@ use std::fmt;
|
|||||||
use std::net::Ipv4Addr;
|
use std::net::Ipv4Addr;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[cfg(feature = "with-serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
use common::{cidr_parts, parse_addr, parse_prefix, IpNetworkError};
|
use common::{cidr_parts, parse_addr, parse_prefix, IpNetworkError};
|
||||||
@ -16,7 +16,7 @@ pub struct Ipv4Network {
|
|||||||
prefix: u8,
|
prefix: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "with-serde")]
|
#[cfg(feature = "serde")]
|
||||||
impl<'de> Deserialize<'de> for Ipv4Network {
|
impl<'de> Deserialize<'de> for Ipv4Network {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
@ -27,7 +27,7 @@ impl<'de> Deserialize<'de> for Ipv4Network {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "with-serde")]
|
#[cfg(feature = "serde")]
|
||||||
impl Serialize for Ipv4Network {
|
impl Serialize for Ipv4Network {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
|
@ -3,7 +3,7 @@ use std::fmt;
|
|||||||
use std::net::Ipv6Addr;
|
use std::net::Ipv6Addr;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
#[cfg(feature = "with-serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
use common::{cidr_parts, parse_prefix, IpNetworkError};
|
use common::{cidr_parts, parse_prefix, IpNetworkError};
|
||||||
@ -18,7 +18,7 @@ pub struct Ipv6Network {
|
|||||||
prefix: u8,
|
prefix: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "with-serde")]
|
#[cfg(feature = "serde")]
|
||||||
impl<'de> Deserialize<'de> for Ipv6Network {
|
impl<'de> Deserialize<'de> for Ipv6Network {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
@ -29,7 +29,7 @@ impl<'de> Deserialize<'de> for Ipv6Network {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "with-serde")]
|
#[cfg(feature = "serde")]
|
||||||
impl Serialize for Ipv6Network {
|
impl Serialize for Ipv6Network {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
#![doc(html_root_url = "https://docs.rs/ipnetwork/0.12.8")]
|
#![doc(html_root_url = "https://docs.rs/ipnetwork/0.12.8")]
|
||||||
|
|
||||||
#[cfg(feature = "with-serde")]
|
#[cfg(feature = "serde")]
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
#[cfg(feature = "with-serde")]
|
#[cfg(feature = "serde")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
|
|
||||||
@ -29,8 +29,8 @@ pub use ipv6::{ipv6_mask_to_prefix, Ipv6Network};
|
|||||||
|
|
||||||
/// Represents a generic network range. This type can have two variants:
|
/// Represents a generic network range. This type can have two variants:
|
||||||
/// the v4 and the v6 case.
|
/// the v4 and the v6 case.
|
||||||
#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
#[cfg_attr(feature = "with-serde", serde(untagged))]
|
#[cfg_attr(feature = "serde", serde(untagged))]
|
||||||
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub enum IpNetwork {
|
pub enum IpNetwork {
|
||||||
V4(Ipv4Network),
|
V4(Ipv4Network),
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#[cfg(feature = "with-serde")]
|
#[cfg(feature = "serde")]
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
#[cfg(feature = "with-serde")]
|
#[cfg(feature = "serde")]
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
#[cfg(feature = "with-serde")]
|
#[cfg(feature = "serde")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ mod tests {
|
|||||||
use ipnetwork::{IpNetwork, Ipv4Network, Ipv6Network};
|
use ipnetwork::{IpNetwork, Ipv4Network, Ipv6Network};
|
||||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||||
|
|
||||||
#[cfg(feature = "with-serde")]
|
#[cfg(feature = "serde")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ipv4_json() {
|
fn test_ipv4_json() {
|
||||||
let json_string = r#"{"ipnetwork":"127.1.0.0/24"}"#;
|
let json_string = r#"{"ipnetwork":"127.1.0.0/24"}"#;
|
||||||
@ -32,7 +32,7 @@ mod tests {
|
|||||||
assert_eq!(::serde_json::to_string(&mystruct).unwrap(), json_string);
|
assert_eq!(::serde_json::to_string(&mystruct).unwrap(), json_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "with-serde")]
|
#[cfg(feature = "serde")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ipv6_json() {
|
fn test_ipv6_json() {
|
||||||
let json_string = r#"{"ipnetwork":"::1/0"}"#;
|
let json_string = r#"{"ipnetwork":"::1/0"}"#;
|
||||||
@ -53,7 +53,7 @@ mod tests {
|
|||||||
assert_eq!(::serde_json::to_string(&mystruct).unwrap(), json_string);
|
assert_eq!(::serde_json::to_string(&mystruct).unwrap(), json_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "with-serde")]
|
#[cfg(feature = "serde")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ipnetwork_json() {
|
fn test_ipnetwork_json() {
|
||||||
let json_string = r#"{"ipnetwork":["127.1.0.0/24","::1/0"]}"#;
|
let json_string = r#"{"ipnetwork":["127.1.0.0/24","::1/0"]}"#;
|
||||||
|
Reference in New Issue
Block a user