Skip to main content

LifecyclePollingNode

Struct LifecyclePollingNode 

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

Standalone lifecycle state machine for no_std environments.

Uses function pointers instead of boxed closures. Does not wrap a NodeHandle — the user manages the node separately.

§Example

fn on_configure() -> TransitionResult {
    // Initialize hardware...
    TransitionResult::Success
}

let mut lifecycle = LifecyclePollingNode::new();
lifecycle.register_on_configure(on_configure);
lifecycle.configure()?;

Implementations§

Source§

impl LifecyclePollingNode

Source

pub const fn new() -> LifecyclePollingNode

Create a new standalone lifecycle state machine.

Starts in the Unconfigured state.

Source

pub const fn state(&self) -> LifecycleState

Get the current lifecycle state.

Source

pub fn trigger_transition( &mut self, transition: LifecycleTransition, ) -> Result<LifecycleState, LifecycleError>

Trigger a lifecycle transition.

Source

pub fn configure(&mut self) -> Result<LifecycleState, LifecycleError>

Convenience: configure (Unconfigured -> Inactive)

Source

pub fn activate(&mut self) -> Result<LifecycleState, LifecycleError>

Convenience: activate (Inactive -> Active)

Source

pub fn deactivate(&mut self) -> Result<LifecycleState, LifecycleError>

Convenience: deactivate (Active -> Inactive)

Source

pub fn cleanup(&mut self) -> Result<LifecycleState, LifecycleError>

Convenience: cleanup (Inactive -> Unconfigured)

Source

pub fn shutdown(&mut self) -> Result<LifecycleState, LifecycleError>

Convenience: shutdown from the current state.

Source

pub fn bring_up(&mut self) -> Result<LifecycleState, LifecycleError>

Convenience: configure then activate (stops on failure).

Source

pub fn register_on_configure(&mut self, cb: fn() -> TransitionResult)

Register a callback for the configure transition.

Source

pub fn register_on_activate(&mut self, cb: fn() -> TransitionResult)

Register a callback for the activate transition.

Source

pub fn register_on_deactivate(&mut self, cb: fn() -> TransitionResult)

Register a callback for the deactivate transition.

Source

pub fn register_on_cleanup(&mut self, cb: fn() -> TransitionResult)

Register a callback for the cleanup transition.

Source

pub fn register_on_shutdown(&mut self, cb: fn() -> TransitionResult)

Register a callback for the shutdown transition.

Source

pub fn register_on_error(&mut self, cb: fn() -> TransitionResult)

Register a callback for the error transition (error recovery).

Trait Implementations§

Source§

impl Default for LifecyclePollingNode

Source§

fn default() -> LifecyclePollingNode

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, 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.