Skip to main content

ResolverContext

Struct ResolverContext 

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

Per-call cache mapping raw pointer of each Pattern in the selector tree to its CompiledPattern. Built once at entry; lookup is O(1) hash.

§Cache reuse across calls

Build a single ResolverContext outside a retry loop and pass it to resolve_selector_compiled / resolve_selector_all_compiled on every iteration to skip the per-call regex compile prepass. The regex hit case drops from ~9.5 µs/iter to ~260 ns/iter on a 15-node tree (see BUDGETS.md). The convenience wrappers resolve_selector / resolve_selector_all keep the per-call construction for one-shot callers.

§Safety

*const Pattern is used only as a HashMap key — never dereferenced. The borrowed Selector passed to ResolverContext::new must outlive every subsequent resolve_selector_compiled call that uses this context. Pattern addresses stay stable for the lifetime of the outer &Selector borrow. Passing a context built from a different Selector than the one being resolved is a runtime contract violation (cache misses degrade to silent None from ctx.pattern).

Implementations§

Source§

impl ResolverContext

Source

pub fn new(selector: &Selector) -> Option<Self>

Build a context by walking the selector tree once and pre-compiling every embedded Pattern. Returns None if any regex pattern fails to compile (matches the silent-None semantic of resolve_selector).

Source

pub fn pattern(&self, p: &Pattern) -> Option<&CompiledPattern>

O(1) cache lookup. Returns None if p was not seen during the build prepass — typically means p belongs to a different selector tree than the one passed to ResolverContext::new.

Trait Implementations§

Auto Trait Implementations§

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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.