Enum cidr::AnyIpCidr
[−]
[src]
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]
fn is_any(&self) -> bool
[src]
Whether representing any address
fn is_ipv4(&self) -> bool
[src]
Whether representing an IPv4 network
fn is_ipv6(&self) -> bool
[src]
Whether representing an IPv6 network
impl AnyIpCidr
[src]
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.
fn new_host(addr: IpAddr) -> Self
[src]
Create a network containing a single address (network length = address length).
fn first_address(&self) -> Option<IpAddr>
[src]
first address in the network as plain address
returns None for Any
fn first(&self) -> Option<IpInet>
[src]
first address in the network
returns None for Any
fn last_address(&self) -> Option<IpAddr>
[src]
last address in the network as plain address
returns None for Any
fn last(&self) -> Option<IpInet>
[src]
last address in the network
returns None for Any
fn network_length(&self) -> Option<u8>
[src]
length in bits of the shared prefix of the contained addresses
returns None for Any
fn family(&self) -> Option<Family>
[src]
IP family of the contained address (Ipv4
or Ipv6
).
returns None for Any
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
fn contains(&self, addr: &IpAddr) -> bool
[src]
check whether an address is contained in the network
Trait Implementations
impl Clone for AnyIpCidr
[src]
fn clone(&self) -> AnyIpCidr
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq for AnyIpCidr
[src]
fn eq(&self, __arg_0: &AnyIpCidr) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &AnyIpCidr) -> bool
[src]
This method tests for !=
.
impl Eq for AnyIpCidr
[src]
impl PartialOrd for AnyIpCidr
[src]
fn partial_cmp(&self, __arg_0: &AnyIpCidr) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &AnyIpCidr) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &AnyIpCidr) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &AnyIpCidr) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &AnyIpCidr) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for AnyIpCidr
[src]
fn cmp(&self, __arg_0: &AnyIpCidr) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl Hash for AnyIpCidr
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Debug for AnyIpCidr
[src]
impl Display for AnyIpCidr
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Into<Option<IpCidr>> for AnyIpCidr
[src]
impl From<Option<IpCidr>> for AnyIpCidr
[src]
impl FromStr for AnyIpCidr
[src]
type Err = NetworkParseError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<AnyIpCidr, NetworkParseError>
[src]
Parses a string s
to return a value of this type. Read more
impl From<IpCidr> for AnyIpCidr
[src]
impl From<Ipv4Cidr> for AnyIpCidr
[src]
impl From<Ipv6Cidr> for AnyIpCidr
[src]
impl BitString for AnyIpCidr
[src]
fn get(&self, ndx: usize) -> bool
[src]
Get the ndx
th bit. Read more
fn set(&mut self, ndx: usize, bit: bool)
[src]
Set the ndx
th bit to bit
. Read more
fn flip(&mut self, ndx: usize)
[src]
Flips the ndx
th bit. Read more
fn len(&self) -> usize
[src]
Current length of the bit string in bits.
fn clip(&mut self, len: usize)
[src]
Set current length to len
. Read more
fn append(&mut self, bit: bool)
[src]
Append a bit. Read more
fn null() -> Self
[src]
Create a new zero-length bit string. Read more
[src]
Length of the longest shared prefix of two bit strings.
[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]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de> Deserialize<'de> for AnyIpCidr
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more