pub struct PhaseLeaser { /* private fields */ }Expand description
The phase leaser manages phase transitions and capability grants. Capabilities are leased for the duration of a phase and automatically revoked when the phase ends or an interrupt occurs.
Implementations§
Source§impl PhaseLeaser
impl PhaseLeaser
Sourcepub fn register_phase(&mut self, phase: Phase) -> Result<(), LeaseError>
pub fn register_phase(&mut self, phase: Phase) -> Result<(), LeaseError>
Register a phase.
Sourcepub fn enter_phase(&mut self, phase_name: &str) -> Result<(), LeaseError>
pub fn enter_phase(&mut self, phase_name: &str) -> Result<(), LeaseError>
Enter a phase. This revokes all previously leased capabilities and grants the capabilities allowed in the new phase.
Sourcepub fn exit_phase(&mut self)
pub fn exit_phase(&mut self)
Exit the current phase. Revokes all leased capabilities.
Sourcepub fn is_leased(&self, cap: &str) -> bool
pub fn is_leased(&self, cap: &str) -> bool
Check if a capability is currently leased (allowed).
Sourcepub fn verify_capability(
&mut self,
cap: &str,
node_id: Option<u32>,
) -> Result<(), LeaseError>
pub fn verify_capability( &mut self, cap: &str, node_id: Option<u32>, ) -> Result<(), LeaseError>
Verify that a capability use is allowed. If not, trigger an interrupt. Returns Ok(()) if allowed, Err(LeaseError) if not.
Sourcepub fn trigger_interrupt(&mut self, interrupt: DeonticInterrupt)
pub fn trigger_interrupt(&mut self, interrupt: DeonticInterrupt)
Trigger a deontic interrupt. Immediately revokes all capabilities and marks the leaser as interrupted.
Sourcepub fn manual_interrupt(&mut self, description: &str)
pub fn manual_interrupt(&mut self, description: &str)
Manually trigger an interrupt (e.g., from governance).
Sourcepub fn resume(&mut self) -> Result<(), LeaseError>
pub fn resume(&mut self) -> Result<(), LeaseError>
Clear the interrupted state and resume (if allowed). This re-grants capabilities for the current phase.
Sourcepub fn active_phase(&self) -> Option<&str>
pub fn active_phase(&self) -> Option<&str>
Get the currently active phase name.
Sourcepub fn interrupts(&self) -> &[DeonticInterrupt]
pub fn interrupts(&self) -> &[DeonticInterrupt]
Get the interrupt history.
Sourcepub fn interrupts_overflowed(&self) -> u64
pub fn interrupts_overflowed(&self) -> u64
Number of interrupt events omitted after the bounded history filled.
Sourcepub fn is_interrupted(&self) -> bool
pub fn is_interrupted(&self) -> bool
Is the leaser in an interrupted state?
Sourcepub fn phase_count(&self) -> usize
pub fn phase_count(&self) -> usize
Get the number of registered phases.
Sourcepub fn leased_count(&self) -> usize
pub fn leased_count(&self) -> usize
Get the number of currently leased capabilities.