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 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
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)));
type Err = NetAddsError
type Err = NetAddsError
The associated error which can be returned from parsing.
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);
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);
Which kind of iterator are we turning this into?
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
Auto Trait Implementations
impl RefUnwindSafe for Ipv6AddrRange
impl Send for Ipv6AddrRange
impl Sync for Ipv6AddrRange
impl Unpin for Ipv6AddrRange
impl UnwindSafe for Ipv6AddrRange
Blanket Implementations
Mutably borrows from an owned value. Read more