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