pub struct PolicyRegistry { /* private fields */ }Expand description
Thread-safe registry of named PolicyConfig instances.
- Reads are lock-free via
ArcSwap(the active policy can be read from any thread without contention). - Writes (register/remove/switch) take a brief
RwLockon the policy map. Since policy changes are rare (operator-initiated), this is not a contention concern.
Implementations§
Source§impl PolicyRegistry
impl PolicyRegistry
Sourcepub fn active_config(&self) -> PolicyConfig
pub fn active_config(&self) -> PolicyConfig
Get the currently active policy config (lock-free).
Sourcepub fn active_name(&self) -> String
pub fn active_name(&self) -> String
Get the name of the currently active policy (lock-free).
Sourcepub fn register(
&self,
name: &str,
config: PolicyConfig,
) -> Result<(), PolicyRegistryError>
pub fn register( &self, name: &str, config: PolicyConfig, ) -> Result<(), PolicyRegistryError>
Register a named policy. Validates before accepting.
Overwrites any existing policy with the same name (except "standard"
which is protected).
Sourcepub fn remove(&self, name: &str) -> Result<(), PolicyRegistryError>
pub fn remove(&self, name: &str) -> Result<(), PolicyRegistryError>
Remove a named policy. Cannot remove "standard" or the currently
active policy.
Sourcepub fn set_active(
&self,
name: &str,
) -> Result<PolicySwitchEvent, PolicyRegistryError>
pub fn set_active( &self, name: &str, ) -> Result<PolicySwitchEvent, PolicyRegistryError>
Switch the active policy to the named policy.
Returns a PolicySwitchEvent recording the transition.
The caller is responsible for emitting it to the evidence ledger
and resetting conformal calibration windows as needed.
Sourcepub fn get(&self, name: &str) -> Option<PolicyConfig>
pub fn get(&self, name: &str) -> Option<PolicyConfig>
Get a specific named policy config, if it exists.
Sourcepub fn switch_count(&self) -> u64
pub fn switch_count(&self) -> u64
Total number of policy switches performed.
Trait Implementations§
Source§impl Debug for PolicyRegistry
impl Debug for PolicyRegistry
Auto Trait Implementations§
impl !Freeze for PolicyRegistry
impl RefUnwindSafe for PolicyRegistry
impl Send for PolicyRegistry
impl Sync for PolicyRegistry
impl Unpin for PolicyRegistry
impl UnsafeUnpin for PolicyRegistry
impl UnwindSafe for PolicyRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more