Enum ipnetwork::IpNetwork [] [src]

pub enum IpNetwork {
    V4(Ipv4Network),
    V6(Ipv6Network),
}

Variants

Methods

impl IpNetwork
[src]

Constructs a new IpNetwork from a given IpAddr and a prefix denoting the network size. If the prefix is larger than 32 (for IPv4) or 128 (for IPv6), this will raise an IpNetworkError::InvalidPrefix error. Support for IPv6 is not complete yet.

Returns the IP part of a given IpNetwork

Example

use std::net::{Ipv4Addr, Ipv6Addr};
use ipnetwork::IpNetwork;

assert_eq!(IpNetwork::V4("10.9.0.32/16".parse().unwrap()).ip(), "10.9.0.32".parse().unwrap());
assert_eq!(IpNetwork::V6("ff01::0/32".parse().unwrap()).ip(), "ff01::0".parse().unwrap());

Returns the prefix of the given IpNetwork

Example

use ipnetwork::IpNetwork;

assert_eq!(IpNetwork::V4("10.9.0.32/16".parse().unwrap()).prefix(), 16u8);
assert_eq!(IpNetwork::V6("ff01::0/32".parse().unwrap()).prefix(), 32u8);

Returns the mask of the given IpNetwork

# Example ``` use ipnetwork::IpNetwork;

assert_eq!(IpNetwork::V4("10.9.0.32/16".parse().unwrap()).mask(), 16u8); assert_eq!(IpNetwork::V6("ff01::0/32".parse().unwrap()).mask(), 32u8); ```

Trait Implementations

impl Debug for IpNetwork
[src]

Formats the value using the given formatter.

impl Clone for IpNetwork
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for IpNetwork
[src]

impl Hash for IpNetwork
[src]

Feeds this value into the state given, updating the hasher as necessary.

Feeds a slice of this type into the state provided.

impl PartialEq for IpNetwork
[src]

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

This method tests for !=.

impl Eq for IpNetwork
[src]