pub struct LifecycleManager { /* private fields */ }Expand description
Manages the lifecycle of a single agent.
Implementations§
Source§impl LifecycleManager
impl LifecycleManager
Sourcepub fn new(agent_id: &str) -> Self
pub fn new(agent_id: &str) -> Self
Create a new lifecycle manager for the given agent.
The initial state is LifecycleState::Provisioning.
Sourcepub fn state(&self) -> LifecycleState
pub fn state(&self) -> LifecycleState
Return the current lifecycle state.
Sourcepub fn events(&self) -> &[LifecycleEvent]
pub fn events(&self) -> &[LifecycleEvent]
Return all recorded lifecycle events.
Sourcepub fn transition(
&mut self,
to: LifecycleState,
reason: &str,
initiated_by: &str,
) -> Result<&LifecycleEvent, String>
pub fn transition( &mut self, to: LifecycleState, reason: &str, initiated_by: &str, ) -> Result<&LifecycleEvent, String>
Attempt to transition the agent to to.
Returns the resulting LifecycleEvent on success, or an error
message describing why the transition is not allowed.
Sourcepub fn can_transition(&self, to: LifecycleState) -> bool
pub fn can_transition(&self, to: LifecycleState) -> bool
Check whether transitioning from the current state to to is valid.
Sourcepub fn activate(&mut self, reason: &str) -> Result<&LifecycleEvent, String>
pub fn activate(&mut self, reason: &str) -> Result<&LifecycleEvent, String>
Convenience: transition to LifecycleState::Active.
Sourcepub fn suspend(&mut self, reason: &str) -> Result<&LifecycleEvent, String>
pub fn suspend(&mut self, reason: &str) -> Result<&LifecycleEvent, String>
Convenience: transition to LifecycleState::Suspended.
Sourcepub fn quarantine(&mut self, reason: &str) -> Result<&LifecycleEvent, String>
pub fn quarantine(&mut self, reason: &str) -> Result<&LifecycleEvent, String>
Convenience: transition to LifecycleState::Quarantined.
Sourcepub fn decommission(&mut self, reason: &str) -> Result<&LifecycleEvent, String>
pub fn decommission(&mut self, reason: &str) -> Result<&LifecycleEvent, String>
Convenience: transition to LifecycleState::Decommissioning.
Auto Trait Implementations§
impl Freeze for LifecycleManager
impl RefUnwindSafe for LifecycleManager
impl Send for LifecycleManager
impl Sync for LifecycleManager
impl Unpin for LifecycleManager
impl UnsafeUnpin for LifecycleManager
impl UnwindSafe for LifecycleManager
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