pub struct Hierarchical<P, C> { /* private fields */ }Expand description
Parent and child state machines with child-first event routing and retained shallow history.
Deactivating a child does not reset it. Reactivating it therefore resumes
its previous state; reset_child explicitly replaces that history.
Implementations§
Source§impl<P, C> Hierarchical<P, C>
impl<P, C> Hierarchical<P, C>
Sourcepub const fn new_active(parent: P, child: C) -> Self
pub const fn new_active(parent: P, child: C) -> Self
Creates a hierarchy whose child starts active.
Sourcepub fn activate_child(&mut self)
pub fn activate_child(&mut self)
Activates the child, preserving its previous state.
Sourcepub fn deactivate_child(&mut self)
pub fn deactivate_child(&mut self)
Deactivates the child while preserving shallow history.
Sourcepub fn reset_child(&mut self, child: C)
pub fn reset_child(&mut self, child: C)
Replaces the child and activates its new initial state.
Sourcepub const fn child_is_active(&self) -> bool
pub const fn child_is_active(&self) -> bool
Returns true when the child is active.
Sourcepub fn parent_mut(&mut self) -> &mut P
pub fn parent_mut(&mut self) -> &mut P
Returns the parent machine mutably.
Sourcepub fn process_event<E, FC, FP>(
&mut self,
event: E,
child_dispatch: FC,
parent_dispatch: FP,
) -> HierarchicalDispatch
pub fn process_event<E, FC, FP>( &mut self, event: E, child_dispatch: FC, parent_dispatch: FP, ) -> HierarchicalDispatch
Routes an event to the active child first and bubbles unhandled events to the parent.
Sourcepub fn process_event_with_completion<E, FC, FP, FT>(
&mut self,
event: E,
child_dispatch: FC,
parent_dispatch: FP,
child_completion: FT,
) -> HierarchicalDispatch
pub fn process_event_with_completion<E, FC, FP, FT>( &mut self, event: E, child_dispatch: FC, parent_dispatch: FP, child_completion: FT, ) -> HierarchicalDispatch
Routes an event like process_event and propagates child termination
to a parent completion callback.
When the callback handles completion, the child is deactivated while retaining its state as shallow history.