Struct ip_network::Ipv6Network
[−]
[src]
pub struct Ipv6Network { /* fields omitted */ }IPv6 Network
Methods
impl Ipv6Network[src]
fn from(network_address: Ipv6Addr, netmask: u8) -> Result<Self, IpNetworkError>[src]
fn from_truncate(
network_address: Ipv6Addr,
netmask: u8
) -> Result<Self, IpNetworkError>[src]
network_address: Ipv6Addr,
netmask: u8
) -> Result<Self, IpNetworkError>
fn get_network_address(&self) -> Ipv6Addr[src]
Returns network IP address (first address in range).
Examples
use std::net::Ipv6Addr; use ipnetwork::Ipv6Network; let ip = Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0); let ip_network = Ipv6Network::from(ip, 32).unwrap(); assert_eq!(ip_network.get_network_address(), ip);
fn get_netmask(&self) -> u8[src]
Returns network mask.
Examples
use std::net::Ipv6Addr; use ipnetwork::Ipv6Network; let ip = Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0); let ip_network = Ipv6Network::from(ip, 32).unwrap(); assert_eq!(ip_network.get_netmask(), 32);
fn contains(&self, ip: Ipv6Addr) -> bool[src]
Returns true if given IP address is inside this network.
Examples
use std::net::Ipv6Addr; use ipnetwork::Ipv6Network; let ip_network = Ipv6Network::from(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0), 64).unwrap(); assert!(ip_network.contains(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 1))); assert!(!ip_network.contains(Ipv6Addr::new(0x2001, 0xdb9, 0, 0, 0, 0, 0, 0)));
fn supernet(&self) -> Self[src]
Returns network with smaller netmask by one.
Examples
use std::net::Ipv6Addr; use ipnetwork::Ipv6Network; let network = Ipv6Network::from(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0), 32).unwrap(); assert_eq!(network.supernet(), Ipv6Network::from(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0), 31).unwrap());
fn subnets(&self) -> Ipv6NetworkIterator[src]
Returns Ipv6NetworkIterator over networks with netmask bigger one.
Examples
use std::net::Ipv6Addr; use ipnetwork::Ipv6Network; let network = Ipv6Network::from(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0), 32).unwrap(); let mut iterator = network.subnets(); assert_eq!(iterator.next().unwrap(), Ipv6Network::from(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0), 33).unwrap()); assert_eq!(iterator.last().unwrap(), Ipv6Network::from(Ipv6Addr::new(0x2001, 0xdb8, 0x8000, 0, 0, 0, 0, 0), 33).unwrap());
fn subnets_with_prefix(&self, prefix: u8) -> Ipv6NetworkIterator[src]
Returns Ipv6NetworkIterator over networks with defined netmask.
Examples
use std::net::Ipv6Addr; use ipnetwork::Ipv6Network; let network = Ipv6Network::from(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0), 32).unwrap(); let mut iterator = network.subnets_with_prefix(33); assert_eq!(iterator.next().unwrap(), Ipv6Network::from(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0), 33).unwrap()); assert_eq!(iterator.last().unwrap(), Ipv6Network::from(Ipv6Addr::new(0x2001, 0xdb8, 0x8000, 0, 0, 0, 0, 0), 33).unwrap());
Trait Implementations
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 Debug for Ipv6Network[src]
impl Eq for Ipv6Network[src]
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 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 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) -> Self1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.22.0[src]
Compares and returns the minimum of two values. Read more
impl Display for Ipv6Network[src]
fn fmt(&self, f: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl FromStr for Ipv6Network[src]
type Err = IpNetworkParseError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Ipv6Network, IpNetworkParseError>[src]
Parses a string s to return a value of this type. Read more