Struct iprange::Subnet [] [src]

pub struct Subnet {
    pub prefix: CompactIpv4,
    pub prefix_size: usize,
}

Represents a subdivision of an IP network.

We use CIDR notation to repesent a subnetwork. Thus, a Subnet is composed with a prefix and the size of the subnet written after a slash (/). The size of the subnet is represented by prefix_size, which is the count of leading ones in the subnet mask.

Subnet implements FromStr so that users can easily convert a string slice to a Subnet. Currently, two formats are supported:

  • a.b.c.d/prefix_size (e.g. 10.0.0.0/8)
  • a.b.c.d/mask (e.g. 192.168.0.0/255.255.255.0)

The subnet will be automatically fixed after parsing. For example: parsing 172.16.32.1/16 results in 172.16.0.0/16.

Fields

The prefix IP of the subnet

The count of leading ones of the subnet mask

Methods

impl Subnet
[src]

[src]

Tests if self contains the IP addr.

[src]

Returns the last IP in self.

[src]

Tests if self includes other, in other words, self is a supernetwork of other.

[src]

Returns the subnet mask of self.

Trait Implementations

impl PartialEq for Subnet
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Eq for Subnet
[src]

impl Clone for Subnet
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for Subnet
[src]

impl From<CompactIpv4> for Subnet
[src]

[src]

Performs the conversion.

impl Debug for Subnet
[src]

[src]

Formats the value using the given formatter.

impl FromStr for Subnet
[src]

The associated error which can be returned from parsing.

[src]

Parses a string s to return a value of this type. Read more