Struct ipnetwork::Ipv6Network
[−]
[src]
pub struct Ipv6Network { /* fields omitted */ }
Represents a network range where the IP addresses are of v6
Methods
impl Ipv6Network
[src]
pub fn new(addr: Ipv6Addr, prefix: u8) -> Result<Ipv6Network, IpNetworkError>
[src]
Constructs a new Ipv6Network
from any Ipv6Addr
and a prefix denoting the network size.
If the prefix is larger than 128 this will return an IpNetworkError::InvalidPrefix
.
pub fn ip(&self) -> Ipv6Addr
[src]
pub fn prefix(&self) -> u8
[src]
pub fn mask(&self) -> Ipv6Addr
[src]
Returns the mask for this Ipv6Network
.
That means the prefix
most significant bits will be 1 and the rest 0
Examples
use std::net::Ipv6Addr; use ipnetwork::Ipv6Network; let net: Ipv6Network = "ff01::0/32".parse().unwrap(); assert_eq!(net.mask(), Ipv6Addr::new(0xffff, 0xffff, 0, 0, 0, 0, 0, 0));
pub fn contains(&self, ip: Ipv6Addr) -> bool
[src]
Checks if a given Ipv6Addr
is in this Ipv6Network
Examples
use std::net::Ipv6Addr; use ipnetwork::Ipv6Network; let net: Ipv6Network = "ff01::0/32".parse().unwrap(); assert!(net.contains(Ipv6Addr::new(0xff01, 0, 0, 0, 0, 0, 0, 0x1))); assert!(!net.contains(Ipv6Addr::new(0xffff, 0, 0, 0, 0, 0, 0, 0x1)));
Trait Implementations
impl Debug for Ipv6Network
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Clone for Ipv6Network
[src]
fn clone(&self) -> Ipv6Network
[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 Copy for Ipv6Network
[src]
impl Hash for Ipv6Network
[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 PartialEq for Ipv6Network
[src]
fn eq(&self, __arg_0: &Ipv6Network) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Ipv6Network) -> bool
[src]
This method tests for !=
.
impl Eq for Ipv6Network
[src]
impl PartialOrd for Ipv6Network
[src]
fn partial_cmp(&self, __arg_0: &Ipv6Network) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Ipv6Network) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Ipv6Network) -> 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: &Ipv6Network) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Ipv6Network) -> 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 Ipv6Network
[src]
fn cmp(&self, __arg_0: &Ipv6Network) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
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 FromStr for Ipv6Network
[src]
type Err = IpNetworkError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Ipv6Network, IpNetworkError>
[src]
Parses a string s
to return a value of this type. Read more
impl From<Ipv6Addr> for Ipv6Network
[src]
fn from(a: Ipv6Addr) -> Ipv6Network
[src]
Performs the conversion.
impl Display for Ipv6Network
[src]
fn fmt(&self, fmt: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl From<Ipv6Network> for IpNetwork
[src]
fn from(v6: Ipv6Network) -> IpNetwork
[src]
Performs the conversion.