[][src]Enum cidr::AnyIpCidr

pub enum AnyIpCidr {
    Any,
    V4(Ipv4Cidr),
    V6(Ipv6Cidr),
}

Represents either an IPv4 or an IPv6 network or "any".

Allows for a bit string representation which treats "any" as the empty string, IPv4 as starting with false and IPv6 as starting with true. After the first bit the normal represenation for the picked address-family follows.

Setting the first bit always truncates the bit string to length 1.

The Cidr trait itself cannot be implemented because Any has no address family, but there is a very similar interface implemented directly.

Variants

Any

"any" network containing all IPv4 and IPv6 addresses

V4(Ipv4Cidr)

IPv4 network

V6(Ipv6Cidr)

IPv6 network

Methods

impl AnyIpCidr[src]

pub fn is_any(&self) -> bool[src]

Whether representing any address

pub fn is_ipv4(&self) -> bool[src]

Whether representing an IPv4 network

pub fn is_ipv6(&self) -> bool[src]

Whether representing an IPv6 network

impl AnyIpCidr[src]

pub fn new(addr: IpAddr, len: u8) -> Result<Self, NetworkParseError>[src]

Create new network from address and prefix length. If the network length exceeds the address length or the address is not the first address in the network ("host part not zero") an error is returned.

pub fn new_host(addr: IpAddr) -> Self[src]

Create a network containing a single address (network length = address length).

pub fn first_address(&self) -> Option<IpAddr>[src]

first address in the network as plain address

returns None for Any

pub fn first(&self) -> Option<IpInet>[src]

first address in the network

returns None for Any

pub fn last_address(&self) -> Option<IpAddr>[src]

last address in the network as plain address

returns None for Any

pub fn last(&self) -> Option<IpInet>[src]

last address in the network

returns None for Any

pub fn network_length(&self) -> Option<u8>[src]

length in bits of the shared prefix of the contained addresses

returns None for Any

pub fn family(&self) -> Option<Family>[src]

IP family of the contained address (Ipv4 or Ipv6).

returns None for Any

pub fn mask(&self) -> Option<IpAddr>[src]

network mask: an pseudo address which has the first network length bits set to 1 and the remaining to 0.

returns None for Any

pub fn contains(&self, addr: &IpAddr) -> bool[src]

check whether an address is contained in the network

Trait Implementations

impl PartialEq<AnyIpCidr> for AnyIpCidr[src]

impl Ord for AnyIpCidr[src]

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

impl Clone for AnyIpCidr[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl From<Option<IpCidr>> for AnyIpCidr[src]

impl From<IpCidr> for AnyIpCidr[src]

impl From<Ipv4Cidr> for AnyIpCidr[src]

impl From<Ipv6Cidr> for AnyIpCidr[src]

impl Into<Option<IpCidr>> for AnyIpCidr[src]

impl Eq for AnyIpCidr[src]

impl PartialOrd<AnyIpCidr> for AnyIpCidr[src]

impl Display for AnyIpCidr[src]

impl Hash for AnyIpCidr[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Debug for AnyIpCidr[src]

impl FromStr for AnyIpCidr[src]

type Err = NetworkParseError

The associated error which can be returned from parsing.

impl BitString for AnyIpCidr[src]

fn shared_prefix(&self, other: &Self) -> Self where
    Self: Clone
[src]

Longest shared prefix of two bit strings.

fn subset_cmp(&self, other: &Self) -> Option<Ordering>[src]

Partial ordering on bit strings. Read more

fn lexicographic_cmp(&self, other: &Self) -> Ordering[src]

Lexicographic ordering on bit strings. Read more

impl Serialize for AnyIpCidr[src]

impl<'de> Deserialize<'de> for AnyIpCidr[src]

Auto Trait Implementations

impl Send for AnyIpCidr

impl Sync for AnyIpCidr

Blanket Implementations

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From for T[src]

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

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

type Owned = T

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]