Struct ip_network::Ipv6Network [−][src]
pub struct Ipv6Network { /* fields omitted */ }
IPv6 Network
Methods
impl Ipv6Network
[src]
impl Ipv6Network
pub fn from(
network_address: Ipv6Addr,
netmask: u8
) -> Result<Self, IpNetworkError>
[src]
pub fn from(
network_address: Ipv6Addr,
netmask: u8
) -> Result<Self, IpNetworkError>
Constructs new Ipv6Network
based on Ipv6Addr
and netmask
.
Returns error if netmask is bigger than 128 or if host bits are set in network_address
.
Examples
use std::net::Ipv6Addr; use ip_network::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.network_address(), ip); assert_eq!(ip_network.netmask(), 32);
pub fn from_truncate(
network_address: Ipv6Addr,
netmask: u8
) -> Result<Self, IpNetworkError>
[src]
pub fn from_truncate(
network_address: Ipv6Addr,
netmask: u8
) -> Result<Self, IpNetworkError>
Constructs new Ipv6Network
based on Ipv6Addr
and netmask
with truncating host bits
from given network_address
.
Returns error if netmask is bigger than 128.
Examples
use std::net::Ipv6Addr; use ip_network::Ipv6Network; let ip = Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 1, 0, 0); let ip_network = Ipv6Network::from_truncate(ip, 32).unwrap(); assert_eq!(ip_network.network_address(), Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0)); assert_eq!(ip_network.netmask(), 32);
pub fn network_address(&self) -> Ipv6Addr
[src]
pub fn network_address(&self) -> Ipv6Addr
Returns network IP address (first address in range).
Examples
use std::net::Ipv6Addr; use ip_network::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.network_address(), ip);
pub fn get_network_address(&self) -> Ipv6Addr
[src]
pub fn get_network_address(&self) -> Ipv6Addr
: please use network_address
instead
pub fn netmask(&self) -> u8
[src]
pub fn netmask(&self) -> u8
Returns network mask.
Examples
use std::net::Ipv6Addr; use ip_network::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.netmask(), 32);
pub fn get_netmask(&self) -> u8
[src]
pub fn get_netmask(&self) -> u8
: please use netmask
instead
pub fn contains(&self, ip: Ipv6Addr) -> bool
[src]
pub fn contains(&self, ip: Ipv6Addr) -> bool
Returns true
if given IP address is inside this network.
Examples
use std::net::Ipv6Addr; use ip_network::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)));
pub fn supernet(&self) -> Self
[src]
pub fn supernet(&self) -> Self
Returns network with smaller netmask by one.
Examples
use std::net::Ipv6Addr; use ip_network::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());
ⓘImportant traits for Ipv6NetworkIteratorpub fn subnets(&self) -> Ipv6NetworkIterator
[src]
pub fn subnets(&self) -> Ipv6NetworkIterator
Returns Ipv6NetworkIterator
over networks with netmask bigger one.
Examples
use std::net::Ipv6Addr; use ip_network::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());
ⓘImportant traits for Ipv6NetworkIteratorpub fn subnets_with_prefix(&self, prefix: u8) -> Ipv6NetworkIterator
[src]
pub fn subnets_with_prefix(&self, prefix: u8) -> Ipv6NetworkIterator
Returns Ipv6NetworkIterator
over networks with defined netmask.
Examples
use std::net::Ipv6Addr; use ip_network::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 From<Ipv6Network> for IpNetwork
[src]
impl From<Ipv6Network> for IpNetwork
fn from(network: Ipv6Network) -> IpNetwork
[src]
fn from(network: Ipv6Network) -> IpNetwork
Performs the conversion.
impl Clone for Ipv6Network
[src]
impl Clone for Ipv6Network
fn clone(&self) -> Ipv6Network
[src]
fn clone(&self) -> Ipv6Network
Returns 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 Debug for Ipv6Network
[src]
impl Debug for Ipv6Network
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Eq for Ipv6Network
[src]
impl Eq for Ipv6Network
impl PartialEq for Ipv6Network
[src]
impl PartialEq for Ipv6Network
fn eq(&self, other: &Ipv6Network) -> bool
[src]
fn eq(&self, other: &Ipv6Network) -> bool
This 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) -> bool
This method tests for !=
.
impl Hash for Ipv6Network
[src]
impl Hash for Ipv6Network
fn 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 PartialOrd for Ipv6Network
[src]
impl PartialOrd for Ipv6Network
fn 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) -> bool
This 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) -> bool
This 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) -> bool
This 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) -> bool
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]
impl Ord for Ipv6Network
fn cmp(&self, other: &Ipv6Network) -> Ordering
[src]
fn cmp(&self, other: &Ipv6Network) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Display for Ipv6Network
[src]
impl Display for Ipv6Network
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Converts Ipv6Network
to string in format X:X::X/Y (CIDR notation).
Examples
use std::net::Ipv6Addr; use ip_network::Ipv6Network; let ip_network = Ipv6Network::from(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0), 32).unwrap(); assert_eq!(format!("{}", ip_network), "2001:db8::/32");
impl FromStr for Ipv6Network
[src]
impl FromStr for Ipv6Network
type Err = IpNetworkParseError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Ipv6Network, IpNetworkParseError>
[src]
fn from_str(s: &str) -> Result<Ipv6Network, IpNetworkParseError>
Parses a string s
to return a value of this type. Read more
Auto Trait Implementations
impl Send for Ipv6Network
impl Send for Ipv6Network
impl Sync for Ipv6Network
impl Sync for Ipv6Network