Skip to main content

ScopePolicyRegistry

Struct ScopePolicyRegistry 

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

Scope policy registry that can be instantiated for isolated testing.

For most use cases, use the global functions (ash_register_scope_policy, etc.) which operate on a shared global registry.

§Pattern Priority (BUG-006 fix)

When multiple patterns could match a binding, the first registered pattern wins. This uses registration order, not alphabetical order, for deterministic matching.

Implementations§

Source§

impl ScopePolicyRegistry

Source

pub fn new() -> Self

Create a new empty registry.

Source

pub fn register(&mut self, binding: &str, fields: &[&str]) -> bool

Register a scope policy for a binding pattern.

Returns false if the pattern is invalid or too complex.

§Pattern Priority (BUG-006)

Later registrations for the same pattern will replace earlier ones. When matching, the first registered pattern that matches wins.

Source

pub fn register_many( &mut self, policies_map: &BTreeMap<&str, Vec<&str>>, ) -> usize

Register multiple scope policies at once.

Returns the number of successfully registered policies.

§Pattern Priority (BUG-034 Warning)

Important: BTreeMap iterates in alphabetical order by key, not insertion order. When you call this method, patterns are registered in alphabetical order of their binding strings.

If you need specific registration order for pattern priority, use multiple calls to register() instead, or use a Vec of tuples and iterate manually.

§Example
// These will be registered in alphabetical order:
// 1. "GET|/api/*|"
// 2. "GET|/api/users|"
// 3. "POST|/api/*|"
// NOT the order you insert them into the BTreeMap!
Source

pub fn get(&self, binding: &str) -> Vec<String>

Get the scope policy for a binding.

§Pattern Priority (BUG-006 fix)

Uses registration order - earlier registered patterns take precedence.

Source

pub fn has(&self, binding: &str) -> bool

Check if a binding has a scope policy defined.

Source

pub fn get_all(&self) -> BTreeMap<String, Vec<String>>

Get all registered policies.

Returns policies in registration order.

Source

pub fn clear(&mut self)

Clear all registered policies.

Trait Implementations§

Source§

impl Debug for ScopePolicyRegistry

Source§

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

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

impl Default for ScopePolicyRegistry

Source§

fn default() -> ScopePolicyRegistry

Returns the “default value” for a type. Read more

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

Source§

type Output = T

Should always be Self
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.