Struct net_adds::Ipv6AddrRange[][src]

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

An IPv6 address range.

See crate::IpAddrRange for a type encompassing both IPv4 and IPv6 range.

The size of an Ipv6AddrRange struct may vary depending on the target operating system.

Textual representation

Ipv6AddrRange provides a FromStr implementation. The two parts are represented by Ipv6Addr and are separated by ‘-’.

Examples

use std::net::Ipv6Addr;

use net_adds::Ipv6AddrRange;

let a = Ipv6Addr::from(0x1);
let b = Ipv6Addr::from(0xA);
let range = Ipv6AddrRange::new(a, b);

assert_eq!(Ok(range), "::1-::A".parse());

Implementations

Returns an Ipv6AddrRange.

Returns the first ip.

Returns the last ip.

Returns all ips included in the range.

Examples:

use std::net::Ipv6Addr;

use net_adds::Ipv6AddrRange;

let a = Ipv6Addr::from(0x1);
let b = Ipv6Addr::from(0x2);
let c = Ipv6Addr::from(0x3);

assert_eq!(Ipv6AddrRange::new(a, c).all(), vec![a, b, c]);
assert_eq!(Ipv6AddrRange::new(c, a).all(), vec![c, b, a]);
assert_eq!(Ipv6AddrRange::new(a, a).all(), vec![a]);

Returns the number of ip’s included in the range.

Examples:

use std::net::Ipv6Addr;

use net_adds::Ipv6AddrRange;

let a = Ipv6Addr::from(0x0);
let b = Ipv6Addr::from(0xA);

let range = Ipv6AddrRange::new(a, b);
assert_eq!(range.size(), 11);

let range = Ipv6AddrRange::new(b, a);
assert_eq!(range.size(), 11);

Returns true if the ip argument is included in the range, else returns false.

Examples:

use std::net::Ipv6Addr;

use net_adds::Ipv6AddrRange;

let a = Ipv6Addr::from(0x0);
let b = Ipv6Addr::from(0xA);

let range = Ipv6AddrRange::new(a, b);

assert!(range.has(Ipv6Addr::from(0x0)));
assert!(range.has(Ipv6Addr::from(0x2)));
assert!(range.has(Ipv6Addr::from(0xA)));

assert!(!range.has(Ipv6Addr::from(0xFFFF)));

let range = Ipv6AddrRange::new(b, a);

assert!(range.has(Ipv6Addr::from(0x0)));
assert!(range.has(Ipv6Addr::from(0x2)));
assert!(range.has(Ipv6Addr::from(0xA)));

assert!(!range.has(Ipv6Addr::from(0xFFFF)));

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

Formats the value using the given formatter. Read more

Create an Ipv6AddrRange from a tuple of two Ipv6Addr.

Examples:

use std::net::Ipv6Addr;

use net_adds::Ipv6AddrRange;

let start = Ipv6Addr::from(0x1);
let end = Ipv6Addr::from(0xA);

assert_eq!(Ipv6AddrRange::from((start, end)), Ipv6AddrRange::new(start, end));

Create an IpAddrRange::V6 from an Ipv6AddrRange.

Examples:

use std::net::Ipv6Addr;

use net_adds::{IpAddrRange, Ipv6AddrRange};

let a = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0);
let b = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0xa);
let range = Ipv6AddrRange::new(a, b);

assert_eq!(IpAddrRange::from(range), IpAddrRange::V6(range));

Parse a string as Ipv6AddrRange.

If the string representation is not valid return an NetAddsError::RangeAddrParse(RangeAddrParseError).

Examples:

use std::net::Ipv6Addr;

use net_adds::Ipv6AddrRange;

let a = Ipv6Addr::new(0xFFFF, 0, 0, 0, 0, 0, 0, 0xFF);
let b = Ipv6Addr::new(0xFFFF, 0, 0, 0, 0, 0, 0, 0xFFFF);

assert_eq!("ffff::ff-ffff::ffff".parse(), Ok(Ipv6AddrRange::new(a, b)));
assert_eq!("ffff:0::ff-ffff::ffff".parse(), Ok(Ipv6AddrRange::new(a, b)));

The associated error which can be returned from parsing.

Feeds this value into the given Hasher. Read more

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

Create a Ipv6Addr iterator.

Examples:

use std::net::Ipv6Addr;

use net_adds::Ipv6AddrRange;

let a = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1);
let b = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 3);
let mut iter = Ipv6AddrRange::new(a, b).into_iter();

assert_eq!(iter.next(), Some(Ipv6Addr::from(1)));
assert_eq!(iter.next(), Some(Ipv6Addr::from(2)));
assert_eq!(iter.next(), Some(Ipv6Addr::from(3)));
assert_eq!(iter.next(), None);

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Create a smart Ipv6Addr iterator.

Examples:

use std::net::Ipv6Addr;

use net_adds::{Ipv6AddrRange, IntoSmartIterator};

let a = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1);
let b = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 3);
let mut iter = Ipv6AddrRange::new(a, b).into_smart_iter();

assert_eq!(iter.next(), Some(Ipv6Addr::from(1)));
assert_eq!(iter.next(), Some(Ipv6Addr::from(2)));
assert_eq!(iter.next(), Some(Ipv6Addr::from(3)));
assert_eq!(iter.next(), None);

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

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

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.