Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ std = []
# Implements "schemars::JsonSchema". Also implies "serde".
json = ["serde", "schemars"]
ser_as_str = ["heapless"]
arbitrary = ["dep:arbitrary"]

[dependencies]
serde = { package = "serde", version = "1", features = ["derive"], optional = true, default-features=false }
schemars = { version = "0.8", optional = true }
heapless = { version = "0", optional = true }
arbitrary = { version = "1", features = ["derive"], optional = true }

[dev-dependencies]
serde_test = "1"
Expand Down
3 changes: 3 additions & 0 deletions src/ipnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use crate::mask::{ip_mask_to_prefix, ipv4_mask_to_prefix, ipv6_mask_to_prefix};
/// assert_eq!(Ok(net.network()), "fd00::".parse());
/// ```
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub enum IpNet {
V4(Ipv4Net),
V6(Ipv6Net),
Expand Down Expand Up @@ -81,6 +82,7 @@ pub enum IpNet {
/// assert_eq!(Ok(net.network()), "10.1.1.0".parse());
/// ```
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct Ipv4Net {
addr: Ipv4Addr,
prefix_len: u8,
Expand Down Expand Up @@ -111,6 +113,7 @@ pub struct Ipv4Net {
/// assert_eq!(Ok(net.network()), "fd00::".parse());
/// ```
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct Ipv6Net {
addr: Ipv6Addr,
prefix_len: u8,
Expand Down