Struct ipnetwork::Ipv6Network
source · [−]pub struct Ipv6Network { /* private fields */ }
Expand description
Represents a network range where the IP addresses are of v6
Implementations
sourceimpl Ipv6Network
impl Ipv6Network
sourcepub fn new(addr: Ipv6Addr, prefix: u8) -> Result<Ipv6Network, IpNetworkError>
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 ip(&self) -> Ipv6Addr
pub fn prefix(&self) -> u8
sourcepub fn mask(&self) -> Ipv6Addr
pub fn mask(&self) -> Ipv6Addr
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));
sourcepub fn contains(&self, ip: Ipv6Addr) -> bool
pub fn contains(&self, ip: Ipv6Addr) -> bool
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
sourceimpl Clone for Ipv6Network
impl Clone for Ipv6Network
sourcefn clone(&self) -> Ipv6Network
fn clone(&self) -> Ipv6Network
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Ipv6Network
impl Debug for Ipv6Network
sourceimpl Display for Ipv6Network
impl Display for Ipv6Network
sourceimpl From<Ipv6Addr> for Ipv6Network
impl From<Ipv6Addr> for Ipv6Network
sourcefn from(a: Ipv6Addr) -> Ipv6Network
fn from(a: Ipv6Addr) -> Ipv6Network
Performs the conversion.
sourceimpl From<Ipv6Network> for IpNetwork
impl From<Ipv6Network> for IpNetwork
sourcefn from(v6: Ipv6Network) -> IpNetwork
fn from(v6: Ipv6Network) -> IpNetwork
Performs the conversion.
sourceimpl FromStr for Ipv6Network
impl FromStr for Ipv6Network
type Err = IpNetworkError
type Err = IpNetworkError
The associated error which can be returned from parsing.
sourcefn from_str(s: &str) -> Result<Ipv6Network, IpNetworkError>
fn from_str(s: &str) -> Result<Ipv6Network, IpNetworkError>
Parses a string s
to return a value of this type. Read more
sourceimpl Hash for Ipv6Network
impl Hash for Ipv6Network
sourceimpl Ord for Ipv6Network
impl Ord for Ipv6Network
sourceimpl PartialEq<Ipv6Network> for Ipv6Network
impl PartialEq<Ipv6Network> for Ipv6Network
sourcefn eq(&self, other: &Ipv6Network) -> bool
fn eq(&self, other: &Ipv6Network) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Ipv6Network) -> bool
fn ne(&self, other: &Ipv6Network) -> bool
This method tests for !=
.
sourceimpl PartialOrd<Ipv6Network> for Ipv6Network
impl PartialOrd<Ipv6Network> for Ipv6Network
sourcefn partial_cmp(&self, other: &Ipv6Network) -> Option<Ordering>
fn partial_cmp(&self, other: &Ipv6Network) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for Ipv6Network
impl Eq for Ipv6Network
impl StructuralEq for Ipv6Network
impl StructuralPartialEq for Ipv6Network
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more