Struct subnetwork::Ipv6

source ·
pub struct Ipv6 { /* private fields */ }

Implementations§

source§

impl Ipv6

source

pub fn new(address: Ipv6Addr) -> Result<Ipv6, AddrParseError>

Constructs a new Ipv6 from a given Ipv6Addr.

source

pub fn from(address: &str) -> Result<Ipv6, AddrParseError>

Constructs a new Ipv6 from a given &str.

source

pub fn iter(&self, netmask: usize) -> Ipv6Pool

Returns an Ipv6 iterator over the addresses contained in the network.

Example
use subnetwork::Ipv6;

fn main() {
    let ipv6 = Ipv6::from("::ffff:192.10.2.255").unwrap();
    for i in ipv6.iter(124) {
        println!("{:?}", i);
    }
}
source

pub fn within_from_str( &self, subnet_address: &str ) -> Result<bool, InvalidInputError>

Check if the ip is within a subnet.

Example
use subnetwork::Ipv6;

fn main() {
    let ipv6 = Ipv6::from("::ffff:192.10.2.255").unwrap();
    let ret = ipv6.within_from_str("::ffff:192.10.2.255/120").unwrap();
    assert_eq!(ret, true);
}
source

pub fn within(&self, subnet_address: Ipv6Pool) -> bool

Check if the ip is within a subnet.

Example
use subnetwork::{Ipv6, Ipv6Pool};

fn main() {
    let ipv6 = Ipv6::from("::ffff:192.10.2.255").unwrap();
    let ipv6_pool = Ipv6Pool::from("::ffff:192.10.2.255/120").unwrap();
    let ret = ipv6.within(ipv6_pool);
    assert_eq!(ret, true);
}
source

pub fn network(&self, netmask: usize) -> Ipv6Addr

Returns the address of the network denoted by this Ipv6. This means the lowest possible IP address inside of the network.

source

pub fn broadcast(&self, netmask: usize) -> Ipv6Addr

Returns the broadcasting address of this Ipv6. This means the highest possible IP address inside of the network.

source

pub fn size(&self, netmask: usize) -> usize

Returns the number of possible host addresses in this Ipv6

source

pub fn len(&self, netmask: usize) -> usize

Returns the number of valid addresses in this Ipv6 (NOT include 0 and 255)

source

pub fn to_std(&self) -> Ipv6Addr

Returns the standard IPv4 address.

Trait Implementations§

source§

impl Clone for Ipv6

source§

fn clone(&self) -> Ipv6

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Ipv6

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Ipv6

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Copy for Ipv6

Auto Trait Implementations§

§

impl RefUnwindSafe for Ipv6

§

impl Send for Ipv6

§

impl Sync for Ipv6

§

impl Unpin for Ipv6

§

impl UnwindSafe for Ipv6

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.