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
impl ScopePolicyRegistry
Sourcepub fn register(&mut self, binding: &str, fields: &[&str]) -> bool
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.
Sourcepub fn register_many(
&mut self,
policies_map: &BTreeMap<&str, Vec<&str>>,
) -> usize
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!Sourcepub fn get(&self, binding: &str) -> Vec<String>
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.