Struct ipnetwork::Ipv6Network [−][src]
pub struct Ipv6Network { /* fields omitted */ }Represents a network range where the IP addresses are of v6
Methods
impl Ipv6Network[src]
impl Ipv6Networkpub fn new(addr: Ipv6Addr, prefix: u8) -> Result<Ipv6Network, IpNetworkError>[src]
pub fn new(addr: Ipv6Addr, prefix: u8) -> Result<Ipv6Network, IpNetworkError>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 iter(&self) -> Ipv6NetworkIterator[src]
pub fn iter(&self) -> Ipv6NetworkIteratorReturns an iterator over Ipv6Network. Each call to next will return the next
Ipv6Addr in the given network. None will be returned when there are no more
addresses.
pub fn network(&self) -> Ipv6Addr[src]
pub fn network(&self) -> Ipv6AddrReturns the address of the network denoted by this Ipv6Network.
This means the lowest possible IPv6 address inside of the network.
Examples
use std::net::Ipv6Addr; use ipnetwork::Ipv6Network; let net: Ipv6Network = "2001:db8::/96".parse().unwrap(); assert_eq!(net.network(), Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0));
pub fn broadcast(&self) -> Ipv6Addr[src]
pub fn broadcast(&self) -> Ipv6AddrReturns the broadcast address of this Ipv6Network.
This means the highest possible IPv4 address inside of the network.
Examples
use std::net::Ipv6Addr; use ipnetwork::Ipv6Network; let net: Ipv6Network = "2001:db8::/96".parse().unwrap(); assert_eq!(net.broadcast(), Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0xffff, 0xffff));
pub fn ip(&self) -> Ipv6Addr[src]
pub fn ip(&self) -> Ipv6Addrpub fn prefix(&self) -> u8[src]
pub fn prefix(&self) -> u8pub fn mask(&self) -> Ipv6Addr[src]
pub fn mask(&self) -> Ipv6AddrReturns 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".parse().unwrap(); assert_eq!(net.mask(), Ipv6Addr::new(0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff)); 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]
pub fn contains(&self, ip: Ipv6Addr) -> boolChecks 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)));
pub fn size(&self) -> u128[src]
pub fn size(&self) -> u128Returns number of possible host addresses in this Ipv6Network.
Examples
use std::net::Ipv6Addr; use ipnetwork::Ipv6Network; let net: Ipv6Network = "ff01::0/32".parse().unwrap(); assert_eq!(net.size(), 79228162514264337593543950336); let tinynet: Ipv6Network = "ff01::0/128".parse().unwrap(); assert_eq!(tinynet.size(), 1);
Trait Implementations
impl Debug for Ipv6Network[src]
impl Debug for Ipv6Networkfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl Clone for Ipv6Network[src]
impl Clone for Ipv6Networkfn clone(&self) -> Ipv6Network[src]
fn clone(&self) -> Ipv6NetworkReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Copy for Ipv6Network[src]
impl Copy for Ipv6Networkimpl Hash for Ipv6Network[src]
impl Hash for Ipv6Networkfn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash<__H: Hasher>(&self, state: &mut __H)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]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, Feeds a slice of this type into the given [Hasher]. Read more
impl PartialEq for Ipv6Network[src]
impl PartialEq for Ipv6Networkfn eq(&self, other: &Ipv6Network) -> bool[src]
fn eq(&self, other: &Ipv6Network) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Ipv6Network) -> bool[src]
fn ne(&self, other: &Ipv6Network) -> boolThis method tests for !=.
impl Eq for Ipv6Network[src]
impl Eq for Ipv6Networkimpl PartialOrd for Ipv6Network[src]
impl PartialOrd for Ipv6Networkfn partial_cmp(&self, other: &Ipv6Network) -> Option<Ordering>[src]
fn partial_cmp(&self, other: &Ipv6Network) -> Option<Ordering>This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &Ipv6Network) -> bool[src]
fn lt(&self, other: &Ipv6Network) -> boolThis method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Ipv6Network) -> bool[src]
fn le(&self, other: &Ipv6Network) -> boolThis method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Ipv6Network) -> bool[src]
fn gt(&self, other: &Ipv6Network) -> boolThis method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Ipv6Network) -> bool[src]
fn ge(&self, other: &Ipv6Network) -> boolThis method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl Ord for Ipv6Network[src]
impl Ord for Ipv6Networkfn cmp(&self, other: &Ipv6Network) -> Ordering[src]
fn cmp(&self, other: &Ipv6Network) -> OrderingThis method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
fn max(self, other: Self) -> SelfCompares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
fn min(self, other: Self) -> SelfCompares and returns the minimum of two values. Read more
impl<'de> Deserialize<'de> for Ipv6Network[src]
impl<'de> Deserialize<'de> for Ipv6Networkfn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>, [src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>, Deserialize this value from the given Serde deserializer. Read more
impl Serialize for Ipv6Network[src]
impl Serialize for Ipv6Networkfn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer, [src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer, Serialize this value into the given Serde serializer. Read more
impl FromStr for Ipv6Network[src]
impl FromStr for Ipv6Networktype Err = IpNetworkError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Ipv6Network, IpNetworkError>[src]
fn from_str(s: &str) -> Result<Ipv6Network, IpNetworkError>Parses a string s to return a value of this type. Read more
impl From<Ipv6Addr> for Ipv6Network[src]
impl From<Ipv6Addr> for Ipv6Networkfn from(a: Ipv6Addr) -> Ipv6Network[src]
fn from(a: Ipv6Addr) -> Ipv6NetworkPerforms the conversion.
impl Display for Ipv6Network[src]
impl Display for Ipv6Networkfn fmt(&self, fmt: &mut Formatter) -> Result[src]
fn fmt(&self, fmt: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl From<Ipv6Network> for IpNetwork[src]
impl From<Ipv6Network> for IpNetworkfn from(v6: Ipv6Network) -> IpNetwork[src]
fn from(v6: Ipv6Network) -> IpNetworkPerforms the conversion.
Auto Trait Implementations
impl Send for Ipv6Network
impl Send for Ipv6Networkimpl Sync for Ipv6Network
impl Sync for Ipv6Network