mod v4;
mod v6;
#[allow(unreachable_pub)] pub use self::v4::Ipv4Cidr;
#[allow(unreachable_pub)]
pub use self::v6::Ipv6Cidr;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum CidrError {
#[error("Failed to parse CIDR: {0}")]
Malformed(String),
#[error("Invalid prefix length")]
InvalidPrefixLength,
}
pub trait Cidr: Sized {
type Addr;
fn address(&self) -> Self::Addr;
fn broadcast(&self) -> Self::Addr;
fn contains(&self, address: Self::Addr) -> bool;
fn hostmask(&self) -> Self::Addr;
fn length(&self) -> usize;
fn netmask(&self) -> Self::Addr;
fn network(&self) -> Self::Addr;
fn new(address: Self::Addr, length: usize) -> Result<Self, CidrError>;
fn size(&self) -> usize;
fn with_netmask(address: Self::Addr, netmask: Self::Addr) -> Result<Self, CidrError>;
}