[][src]Enum ipnet::IpSubnets

pub enum IpSubnets {
    V4(Ipv4Subnets),
    V6(Ipv6Subnets),
}

An Iterator that generates IP network addresses, either IPv4 or IPv6.

Generates the subnets between the provided start and end IP addresses inclusive of end. Each iteration generates the next network address of the largest valid size it can, while using a prefix lenth not less than min_prefix_len.

Examples

let subnets = IpSubnets::from(Ipv4Subnets::new(
    "10.0.0.0".parse().unwrap(),
    "10.0.0.239".parse().unwrap(),
    26,
));
 
assert_eq!(subnets.collect::<Vec<IpNet>>(), vec![
    "10.0.0.0/26".parse().unwrap(),
    "10.0.0.64/26".parse().unwrap(),
    "10.0.0.128/26".parse().unwrap(),
    "10.0.0.192/27".parse().unwrap(),
    "10.0.0.224/28".parse().unwrap(),
]);

let subnets = IpSubnets::from(Ipv6Subnets::new(
    "fd00::".parse().unwrap(),
    "fd00:ef:ffff:ffff:ffff:ffff:ffff:ffff".parse().unwrap(),
    26,
));
 
assert_eq!(subnets.collect::<Vec<IpNet>>(), vec![
    "fd00::/26".parse().unwrap(),
    "fd00:40::/26".parse().unwrap(),
    "fd00:80::/26".parse().unwrap(),
    "fd00:c0::/27".parse().unwrap(),
    "fd00:e0::/28".parse().unwrap(),
]);

Variants

Trait Implementations

impl Clone for IpSubnets[src]

impl Copy for IpSubnets[src]

impl Debug for IpSubnets[src]

impl Eq for IpSubnets[src]

impl From<Ipv4Subnets> for IpSubnets[src]

impl From<Ipv6Subnets> for IpSubnets[src]

impl FusedIterator for IpSubnets[src]

impl Hash for IpSubnets[src]

impl Iterator for IpSubnets[src]

type Item = IpNet

The type of the elements being iterated over.

impl Ord for IpSubnets[src]

impl PartialEq<IpSubnets> for IpSubnets[src]

impl PartialOrd<IpSubnets> for IpSubnets[src]

impl StructuralEq for IpSubnets[src]

impl StructuralPartialEq for IpSubnets[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.