pub trait IPExt: Clone + Copy {
type Error;
type LenType;
fn next_ip(&self, prefix_length: u8, n: Self::LenType) -> Result<Self, Self::Error>
where
Self: Sized;
fn num_ips(block: &str) -> Result<Self::LenType, Self::Error>
where
Self: Sized;
}
impl IPExt for std::net::Ipv4Addr {
type Error = super::Error;
type LenType = u32;
fn next_ip(&self, prefix_length: u8, n: u32) -> Result<Self, Self::Error> {
super::next_ip_v4(*self, prefix_length, n)
}
fn num_ips(block: &str) -> Result<u32, Self::Error> {
super::v4_num_ips(block)
}
}
impl IPExt for std::net::Ipv6Addr {
type Error = super::Error;
type LenType = u128;
fn next_ip(&self, prefix_length: u8, n: u128) -> Result<Self, Self::Error> {
super::next_ip_v6(*self, prefix_length, n)
}
fn num_ips(block: &str) -> Result<u128, Self::Error> {
super::v6_num_ips(block)
}
}