pub struct LifecyclePollingNodeCtx { /* private fields */ }Expand description
Lifecycle state machine with unsafe fn(*mut c_void) -> TransitionResult callbacks.
Thin counterpart to LifecyclePollingNode for bridging the C FFI: each
callback slot stores a pointer to extern "C" user code plus a single
shared *mut c_void context that is passed on every invocation. The core
state machine logic comes from nros_core::lifecycle, same as
LifecyclePollingNode.
Implementations§
Source§impl LifecyclePollingNodeCtx
impl LifecyclePollingNodeCtx
Sourcepub const fn new() -> LifecyclePollingNodeCtx
pub const fn new() -> LifecyclePollingNodeCtx
Create a new standalone lifecycle state machine. Starts in Unconfigured.
Sourcepub const fn state(&self) -> LifecycleState
pub const fn state(&self) -> LifecycleState
Get the current lifecycle state.
Sourcepub fn set_context(&mut self, ctx: *mut c_void)
pub fn set_context(&mut self, ctx: *mut c_void)
Set the user context pointer passed to every callback.
Sourcepub fn register(
&mut self,
slot: LifecycleCallbackSlot,
cb: Option<unsafe extern "C" fn(*mut c_void) -> u8>,
)
pub fn register( &mut self, slot: LifecycleCallbackSlot, cb: Option<unsafe extern "C" fn(*mut c_void) -> u8>, )
Register / clear the callback for a given transition slot.
Sourcepub fn clear_callbacks(&mut self)
pub fn clear_callbacks(&mut self)
Clear every registered callback. Used on fini.
Sourcepub unsafe fn trigger_transition(
&mut self,
transition: LifecycleTransition,
) -> Result<LifecycleState, LifecycleError>
pub unsafe fn trigger_transition( &mut self, transition: LifecycleTransition, ) -> Result<LifecycleState, LifecycleError>
Trigger a lifecycle transition.
§Safety
The registered callback (if any) is called via a raw unsafe fn pointer
with the stored *mut c_void context. The caller must guarantee that
any registered callback / context pair remains valid.