Skip to main content

CompiledIpFilter

Struct CompiledIpFilter 

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

Precompiled zero-allocation IP filter engine backing IpFilterPlugin.

Implementations§

Source§

impl CompiledIpFilter

Inherent compilation, IP resolution, and filtering engine for CompiledIpFilter.

Source

pub fn compile(config: IpFilterConfig) -> Self

Precompiles config into radix CIDR tables and a pre-serialized rejection wire buffer.

§Arguments
  • IpFilterConfig - Source filter policy.
§Returns
  • Self - Compiled zero-allocation IP filter.
Source

pub fn get_config(&self) -> &IpFilterConfig

Returns the source IpFilterConfig.

§Returns
  • &IpFilterConfig - Source configuration.
Source

pub fn get_prebuilt_reject_wire(&self) -> &Vec<u8> ⓘ

Returns the pre-serialized HTTP rejection response wire bytes.

§Returns
  • &Vec<u8> - Prebuilt wire response buffer.
Source

pub fn is_path_exempt(&self, path: &str) -> bool

Reports whether path is exempted from allowlist/denylist enforcement.

§Arguments
  • &str - Incoming request path.
§Returns
  • bool - true when exempt.
Source

pub fn resolve_client_ip( &self, peer_ip: Option<IpAddr>, headers: &RequestHeaders, ) -> Option<ClientIp>

Resolves the real client IP from peer_ip and trusted forwarding headers with zero heap allocations.

Forwarding headers are strictly ignored unless peer_ip matches trusted_proxies.

§Arguments
  • Option<IpAddr> - Direct transport peer IP address.
  • &RequestHeaders - Incoming request headers.
§Returns
  • Option<ClientIp> - Resolved client IP metadata.
Source

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

Evaluates whether ip is permitted by the compiled denylist and allowlist.

Denylist rules always take precedence over allowlist rules.

§Arguments
  • IpAddr - Resolved client IP.
§Returns
  • bool - true when permitted; false when rejected.
Source

pub fn evaluate( &self, peer_ip: Option<IpAddr>, ctx: &mut Context, ) -> IpFilterDecision

Resolves ClientIp, stores it in ctx under ATTR_CLIENT_IP, and enforces allow/deny rules.

§Arguments
  • Option<IpAddr> - Direct transport peer IP address.
  • &mut Context - Incoming request and outgoing response context.
§Returns
  • IpFilterDecision - Enforcement outcome and resolved client IP metadata.

Trait Implementations§

Source§

impl Clone for CompiledIpFilter

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 CompiledIpFilter

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for CompiledIpFilter

§

impl Freeze for CompiledIpFilter

§

impl Move for CompiledIpFilter

§

impl RefUnwindSafe for CompiledIpFilter

§

impl Send for CompiledIpFilter
where RawVecInner: Send, BoxRaw<V4CidrCsr>: Send, BoxRaw<V6CidrCsr>: Send, BoxRaw<[String]>: Send, RawTable<(String, ())>: Send,

§

impl Sync for CompiledIpFilter
where RawVecInner: Sync, BoxRaw<V4CidrCsr>: Sync, BoxRaw<V6CidrCsr>: Sync, BoxRaw<[String]>: Sync, RawTable<(String, ())>: Sync,

§

impl Unpin for CompiledIpFilter
where *const u8 is !null: Unpin, Box<V4CidrCsr>: Unpin, Box<V6CidrCsr>: Unpin, Box<[String]>: Unpin,

§

impl UnsafeUnpin for CompiledIpFilter

§

impl UnwindSafe for CompiledIpFilter
where RawVecInner: UnwindSafe, BoxRaw<V4CidrCsr>: UnwindSafe, BoxRaw<V6CidrCsr>: UnwindSafe, BoxRaw<[String]>: UnwindSafe, NonNull<u8>: 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