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
impl LightweightRtObject
Sourcepub fn new(callbacks: Box<dyn ComponentAction>) -> Self
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.
Sourcepub fn initialize(&mut self) -> ReturnCode
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.”
Sourcepub fn finalize(&mut self) -> ReturnCode
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.”
Sourcepub const fn is_alive(&self) -> bool
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”.
Sourcepub fn attach_context(&mut self) -> Result<ExecutionContextHandle, ReturnCode>
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.”
Sourcepub fn detach_context(&mut self, handle: ExecutionContextHandle) -> ReturnCode
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”.
Sourcepub fn get_participating_contexts(&self) -> Vec<ExecutionContextHandle> ⓘ
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.
Sourcepub fn get_context_state(
&self,
handle: ExecutionContextHandle,
) -> Option<LifeCycleState>
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.
Sourcepub fn transition_to_error(&mut self, handle: ExecutionContextHandle)
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).
Sourcepub fn callbacks_mut(&mut self) -> &mut dyn ComponentAction
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.