pub struct IpSet { /* private fields */ }Expand description
A collection of unique IP addresses stored as sorted, non-overlapping ranges.
Handles automatic merging of overlapping and adjacent ranges lazily.
Implementations§
Source§impl IpSet
impl IpSet
Sourcepub fn insert(&mut self, ip: IpAddr)
pub fn insert(&mut self, ip: IpAddr)
Adds a single IP address to the set.
This is a fast $O(1)$ operation that defers merging.
Sourcepub fn insert_range(&mut self, range: IpRange)
pub fn insert_range(&mut self, range: IpRange)
Adds a unified IP range to the set.
Sourcepub fn push_v4_range(&mut self, range: Ipv4Range)
pub fn push_v4_range(&mut self, range: Ipv4Range)
Appends an IPv4 range without immediate merging.
Sourcepub fn push_v6_range(&mut self, range: Ipv6Range)
pub fn push_v6_range(&mut self, range: Ipv6Range)
Appends an IPv6 range without immediate merging.
Sourcepub fn canonicalize(&mut self)
pub fn canonicalize(&mut self)
Manually triggers sorting and merging of all internal ranges.
Call this after bulk insertions to prepare the set for high-performance read-only queries or multithreaded scanning.
Sourcepub fn contains(&self, ip: &IpAddr) -> bool
pub fn contains(&self, ip: &IpAddr) -> bool
Checks if the set contains the given IP address. Performs lazy merging on a clone if needed.
Sourcepub fn len(&self) -> u128
pub fn len(&self) -> u128
Returns the total count of unique IP addresses. Performs lazy merging on a clone if needed.
Sourcepub fn iter(&self) -> Box<dyn Iterator<Item = IpAddr> + Send + '_>
pub fn iter(&self) -> Box<dyn Iterator<Item = IpAddr> + Send + '_>
Returns an iterator over every individual IP address. Performs lazy merging on a clone if needed.
Sourcepub fn contains_canonical(&self, ip: &IpAddr) -> bool
pub fn contains_canonical(&self, ip: &IpAddr) -> bool
A high-performance, thread-safe version of contains.
§Panics
Panics in debug mode if the set has pending unmerged ranges.
Sourcepub fn len_canonical(&self) -> u128
pub fn len_canonical(&self) -> u128
Trait Implementations§
impl Eq for IpSet
Source§impl Extend<IpAddr> for IpSet
impl Extend<IpAddr> for IpSet
Source§fn extend<T: IntoIterator<Item = IpAddr>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = IpAddr>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl FromIterator<IpAddr> for IpSet
impl FromIterator<IpAddr> for IpSet
Source§impl FromIterator<IpRange> for IpSet
impl FromIterator<IpRange> for IpSet
Source§impl FromIterator<IpSet> for IpSet
impl FromIterator<IpSet> for IpSet
Source§impl IntoIterator for IpSet
impl IntoIterator for IpSet
impl StructuralPartialEq for IpSet
Auto Trait Implementations§
impl Freeze for IpSet
impl RefUnwindSafe for IpSet
impl Send for IpSet
impl Sync for IpSet
impl Unpin for IpSet
impl UnsafeUnpin for IpSet
impl UnwindSafe for IpSet
Blanket Implementations§
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§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<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