Skip to main content

CidrTable

Struct CidrTable 

Source
pub struct CidrTable { /* private fields */ }
Expand description

Zero-allocation /8 radix-indexed IPv4/IPv6 CIDR lookup table using merged disjoint intervals.

Implementations§

Source§

impl CidrTable

Inherent compilation and zero-allocation lookup methods for CidrTable.

Source

pub fn from_nets(nets: &[IpNet]) -> Self

Compiles a slice of IpNet blocks into a /8 radix-indexed lookup table.

§Arguments
  • &[IpNet] - Source CIDR entries.
§Returns
  • Self - Compiled lookup table ready for zero-allocation queries.
Source

pub fn is_empty(&self) -> bool

Reports whether this table contains zero CIDR entries.

§Returns
  • bool - true when empty.
Source

pub fn len(&self) -> usize

Returns the number of CIDR entries compiled into this table.

§Returns
  • usize - Entry count.
Source

pub fn contains(&self, ip: IpAddr) -> bool

Tests whether ip matches any compiled CIDR entry without heap allocation.

IPv4-mapped IPv6 addresses (::ffff:a.b.c.d) are canonicalized to IPv4 prior to lookup.

§Arguments
  • IpAddr - Candidate IP address.
§Returns
  • bool - true when ip matches at least one entry.
Source

pub fn contains_v4(&self, ip: Ipv4Addr) -> bool

Zero-allocation IPv4 lookup using /8 radix indexing and binary search.

§Arguments
  • Ipv4Addr - Candidate IPv4 address.
§Returns
  • bool - true when matched.
Source

pub fn contains_v6(&self, ip: Ipv6Addr) -> bool

Zero-allocation IPv6 lookup using /8 radix indexing and binary search.

§Arguments
  • Ipv6Addr - Candidate IPv6 address (must not be IPv4-mapped).
§Returns
  • bool - true when matched.

Trait Implementations§

Source§

impl Clone for CidrTable

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CidrTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CidrTable

Default construction for CidrTable.

Source§

fn default() -> Self

Constructs an empty CidrTable.

§Returns
  • Self - Empty CIDR lookup table.

Auto Trait Implementations§

§

impl Forget for CidrTable

§

impl Freeze for CidrTable
where *const V4CidrCsr is !null: Freeze, PhantomData<V4CidrCsr>: Freeze, *const V6CidrCsr is !null: Freeze, PhantomData<V6CidrCsr>: Freeze,

§

impl Move for CidrTable

§

impl RefUnwindSafe for CidrTable

§

impl Send for CidrTable
where BoxRaw<V4CidrCsr>: Send, BoxRaw<V6CidrCsr>: Send,

§

impl Sync for CidrTable
where BoxRaw<V4CidrCsr>: Sync, BoxRaw<V6CidrCsr>: Sync,

§

impl Unpin for CidrTable
where Box<V4CidrCsr>: Unpin, Box<V6CidrCsr>: Unpin,

§

impl UnsafeUnpin for CidrTable
where *const V4CidrCsr is !null: UnsafeUnpin, PhantomData<V4CidrCsr>: UnsafeUnpin, *const V6CidrCsr is !null: UnsafeUnpin, PhantomData<V6CidrCsr>: UnsafeUnpin,

§

impl UnwindSafe for CidrTable
where BoxRaw<V4CidrCsr>: UnwindSafe, BoxRaw<V6CidrCsr>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnySend for T
where T: Any + Send,

Source§

impl<T> AnySendClone for T
where T: Any + Send + Clone,

Source§

impl<T> AnySendSync for T
where T: Any + Send + Sync,

Source§

impl<T> AnySendSyncClone for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> AnySync for T
where T: Any + Sync,

Source§

impl<T> AnySyncClone for T
where T: Any + Sync + Clone,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more