Skip to main content

LightweightRtObject

Struct LightweightRtObject 

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

LightweightRTObject — spec §5.2.2.2 (p. 12-19).

Manages:

  • Lifecycle state per execution context (spec §5.2.2.3).
  • List of all contexts in which the RTC participates.
  • Owner-context handle (the RTC can itself be the owner of a context — autonomous RTC, spec §5.2.2.5).
  • Reference to the ComponentAction callbacks (Box<dyn> so the caller can plug in its own behavior).

The state machine is enforced centrally here — all operations check preconditions and return PRECONDITION_NOT_MET on error (spec §5.2.2.2.x).

Implementations§

Source§

impl LightweightRtObject

Source

pub fn new(callbacks: Box<dyn ComponentAction>) -> Self

Constructs a new, not-yet-initialized RTC in the Created state. Spec §5.2.2.3.1.

Source

pub fn initialize(&mut self) -> ReturnCode

Spec §5.2.2.2.1 — initialize: Created → Alive (Inactive in jedem attached Context).

“An RTC may be initialized only while it is in the Created state. Any attempt to invoke this operation while in another state shall fail with PRECONDITION_NOT_MET.”

Source

pub fn finalize(&mut self) -> ReturnCode

Spec §5.2.2.2.2 — finalize: Alive → Created (no longer attached to any context).

“An RTC may not be finalized while it is participating in any execution context.”

Source

pub const fn is_alive(&self) -> bool

Spec §5.2.2.2.3 — is_alive. “is alive or not regardless of the execution context from which it is observed”.

Source

pub fn attach_context(&mut self) -> Result<ExecutionContextHandle, ReturnCode>

Spec §5.2.2.2.5 — attach_context: registers the RTC for a context. Returns a new handle.

“This operation is intended to be invoked by ExecutionContextOperations::add_component. It is not intended for use by other clients.”

Source

pub fn detach_context(&mut self, handle: ExecutionContextHandle) -> ReturnCode

Spec §5.2.2.2.6 — detach_context. “may not be invoked if this RTC is Active in the indicated execution context”.

Source

pub fn get_participating_contexts(&self) -> Vec<ExecutionContextHandle>

Spec §5.2.2.2.9 — get_participating_contexts. Returns a list of the handles this RTC participates in.

Source

pub fn get_context_state( &self, handle: ExecutionContextHandle, ) -> Option<LifeCycleState>

Spec §5.2.2.6.x invoked via the caller — checks whether the RTC is in the expected state in the given context.

Source

pub fn transition_to_error(&mut self, handle: ExecutionContextHandle)

Forces Active → Error after a callback error in user code. Spec §5.2.2.4.7 — on_aborting is invoked once, after which on_error takes over (see the periodic-tick loop).

Source

pub fn callbacks_mut(&mut self) -> &mut dyn ComponentAction

Returns mutable access to the callbacks. Needed by the ExecutionContext::tick loop to invoke the periodic on_execute/on_state_update/on_error callbacks.

Trait Implementations§

Source§

impl Debug for LightweightRtObject

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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.