[−][src]Enum cidr::AnyIpCidr
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 cmp(&self, other: &AnyIpCidr) -> Ordering
[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(&self) -> 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]
fn partial_cmp(&self, other: &AnyIpCidr) -> Option<Ordering>
[src]
fn lt(&self, other: &AnyIpCidr) -> bool
[src]
fn le(&self, other: &AnyIpCidr) -> bool
[src]
fn gt(&self, other: &AnyIpCidr) -> bool
[src]
fn ge(&self, other: &AnyIpCidr) -> bool
[src]
impl Display for AnyIpCidr
[src]
impl Hash for AnyIpCidr
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
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 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]
impl BitString for AnyIpCidr
[src]
fn get(&self, ndx: usize) -> bool
[src]
fn set(&mut self, ndx: usize, bit: bool)
[src]
fn flip(&mut self, ndx: usize)
[src]
fn len(&self) -> usize
[src]
fn clip(&mut self, len: usize)
[src]
fn append(&mut self, bit: bool)
[src]
fn null() -> Self
[src]
fn shared_prefix_len(&self, other: &Self) -> usize
[src]
fn shared_prefix(&self, other: &Self) -> Self where
Self: Clone,
[src]
Self: Clone,
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]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Auto Trait Implementations
Blanket Implementations
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,