pub enum IpRange {
V4(Ipv4Range),
V6(Ipv6Range),
}Expand description
Either family’s range, for a caller that does not care which it was handed.
What FromStr produces, since the text decides the family.
Not #[non_exhaustive]: there is no third address family, so matching both arms is
exhaustive.
Variants§
Implementations§
Source§impl IpRange
impl IpRange
Sourcepub fn iter(&self) -> Box<dyn Iterator<Item = IpAddr> + Send + '_>
pub fn iter(&self) -> Box<dyn Iterator<Item = IpAddr> + Send + '_>
Every address the range holds, ascending.
Boxed, since the families iterate as different types, as in
IpSet::iter. Iterating a wide IPv6 range does not
finish.
Sourcepub fn start_addr(&self) -> IpAddr
pub fn start_addr(&self) -> IpAddr
Returns the start address of the range as an IpAddr.
Sourcepub fn contains(&self, ip: &IpAddr) -> bool
pub fn contains(&self, ip: &IpAddr) -> bool
Checks if the given IpAddr falls within this range.
Returns false if the protocol versions do not match (e.g., checking
if a V6 address is in a V4 range).
Sourcepub fn len(&self) -> u128
pub fn len(&self) -> u128
How many addresses the range covers, never fewer than one. See
Ipv4Range::len for why there is no is_empty beside it.
Trait Implementations§
impl Copy for IpRange
impl Eq for IpRange
Source§impl From<&IpRange> for RangeRecord
impl From<&IpRange> for RangeRecord
Source§impl FromIterator<IpRange> for IpSet
impl FromIterator<IpRange> for IpSet
Source§impl FromStr for IpRange
impl FromStr for IpRange
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parses an IP range from a string.
Supports:
- CIDR notation:
192.0.2.0/24,2001:db8::/32 - Hyphenated ranges:
198.51.100.1-198.51.100.5,::1-::f - Shortened IPv4 ranges, where the end continues the start’s octets:
10.0.0.1-50,192.168.1.1-2.254 - Single IPs:
1.1.1.1,::1
The whole range grammar: everything in the crate that reads a written range ends here.
impl StructuralPartialEq for IpRange
Auto Trait Implementations§
impl Freeze for IpRange
impl RefUnwindSafe for IpRange
impl Send for IpRange
impl Sync for IpRange
impl Unpin for IpRange
impl UnsafeUnpin for IpRange
impl UnwindSafe for IpRange
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more