Skip to main content

LifecyclePollingNodeCtx

Struct LifecyclePollingNodeCtx 

Source
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

Source

pub const fn new() -> Self

Create a new standalone lifecycle state machine. Starts in Unconfigured.

Source

pub const fn state(&self) -> LifecycleState

Get the current lifecycle state.

Source

pub fn set_context(&mut self, ctx: *mut c_void)

Set the user context pointer passed to every callback.

Source

pub fn context(&self) -> *mut c_void

Get the user context pointer.

Source

pub fn register( &mut self, slot: LifecycleCallbackSlot, cb: Option<LifecycleCallbackFnCtx>, )

Register / clear the callback for a given transition slot.

Source

pub fn clear_callbacks(&mut self)

Clear every registered callback. Used on fini.

Source

pub fn finalize(&mut self)

Force the state to Finalized. Used on fini.

Source

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.

Trait Implementations§

Source§

impl Default for LifecyclePollingNodeCtx

Source§

fn default() -> Self

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.