Struct ipnetwork::Ipv6Network[][src]

pub struct Ipv6Network { /* fields omitted */ }
Expand description

Represents a network range where the IP addresses are of v6

Implementations

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.

Constructs a new Ipv6Network from a network address and a network mask.

If the netmask is not valid this will return an IpNetworkError::InvalidPrefix.

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.

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

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

Checks if the given Ipv6Network is a subnet of the other.

Checks if the given Ipv6Network is a supernet of the other.

Checks if the given Ipv6Network is partly contained in other.

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

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

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Creates an Ipv6Network from parsing a string in CIDR notation.

Examples

use std::net::Ipv6Addr;
use ipnetwork::Ipv6Network;

let new = Ipv6Network::new(Ipv6Addr::new(0xff01, 0, 0, 0x17, 0, 0, 0, 0x2), 65).unwrap();
let from_cidr: Ipv6Network = "FF01:0:0:17:0:0:0:2/65".parse().unwrap();
assert_eq!(new.ip(), from_cidr.ip());
assert_eq!(new.prefix(), from_cidr.prefix());

The associated error which can be returned from parsing.

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

Feeds this value into the given Hasher. Read more

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

Which kind of iterator are we turning this into?

The type of the elements being iterated over.

Creates an iterator from a value. Read more

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

Restrict a value to a certain interval. Read more

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

This method tests for !=.

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

Serialize this value into the given Serde serializer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.