Struct ipnetwork::Ipv6Network [−][src]
Represents a network range where the IP addresses are of v6
Implementations
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 iter(&self) -> Ipv6NetworkIterator
[src]
Returns 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]
Returns 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]
Returns 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 prefix(&self) -> u8
[src]
pub fn is_subnet_of(self, other: Ipv6Network) -> bool
[src]
Checks if the given Ipv6Network
is a subnet of the other.
pub fn is_supernet_of(self, other: Ipv6Network) -> bool
[src]
Checks if the given Ipv6Network
is a supernet of the other.
pub fn overlaps(self, other: Ipv6Network) -> bool
[src]
Checks if the given Ipv6Network
is partly contained in other.
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".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]
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)));
pub fn size(&self) -> u128
[src]
Returns 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 Clone for Ipv6Network
[src]
fn clone(&self) -> Ipv6Network
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Ipv6Network
[src]
impl Debug for Ipv6Network
[src]
impl<'de> Deserialize<'de> for Ipv6Network
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Display for Ipv6Network
[src]
impl Eq for Ipv6Network
[src]
impl From<Ipv6Addr> for Ipv6Network
[src]
fn from(a: Ipv6Addr) -> Ipv6Network
[src]
impl From<Ipv6Network> for IpNetwork
[src]
fn from(v6: Ipv6Network) -> IpNetwork
[src]
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]
impl Hash for Ipv6Network
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Ipv6Network
[src]
fn cmp(&self, other: &Ipv6Network) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<Ipv6Network> for Ipv6Network
[src]
fn eq(&self, other: &Ipv6Network) -> bool
[src]
fn ne(&self, other: &Ipv6Network) -> bool
[src]
impl PartialOrd<Ipv6Network> for Ipv6Network
[src]
fn partial_cmp(&self, other: &Ipv6Network) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for Ipv6Network
[src]
impl StructuralEq for Ipv6Network
[src]
impl StructuralPartialEq for Ipv6Network
[src]
Auto Trait Implementations
impl RefUnwindSafe for Ipv6Network
impl Send for Ipv6Network
impl Sync for Ipv6Network
impl Unpin for Ipv6Network
impl UnwindSafe for Ipv6Network
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,