Struct ip_network::Ipv6Network[][src]

pub struct Ipv6Network { /* fields omitted */ }

IPv6 Network

Methods

impl Ipv6Network
[src]

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);

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);

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);

Deprecated since 0.2.2

: please use network_address instead

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);

Deprecated since 0.2.2

: please use netmask instead

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)));

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 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 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]

Performs the conversion.

impl Clone for Ipv6Network
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Ipv6Network
[src]

Formats the value using the given formatter. Read more

impl Eq for Ipv6Network
[src]

impl PartialEq for Ipv6Network
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Hash for Ipv6Network
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl PartialOrd for Ipv6Network
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl Display for Ipv6Network
[src]

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]

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Auto Trait Implementations

impl Send for Ipv6Network

impl Sync for Ipv6Network