pub struct ModeManager { /* private fields */ }Expand description
Central coordinator for mode lifecycle and transitions
The ModeManager is responsible for:
- Registering and managing available modes
- Switching between modes
- Maintaining the current mode state
- Managing the execution context
Implementations§
Source§impl ModeManager
impl ModeManager
Sourcepub fn new(context: ModeContext) -> Self
pub fn new(context: ModeContext) -> Self
Create a new mode manager with the given context
Sourcepub fn register_mode(&mut self, mode: Arc<dyn Mode>)
pub fn register_mode(&mut self, mode: Arc<dyn Mode>)
Register a mode
Sourcepub fn list_modes(&self) -> Vec<Arc<dyn Mode>>
pub fn list_modes(&self) -> Vec<Arc<dyn Mode>>
Get all registered modes
Sourcepub async fn switch_mode(&self, mode_id: &str) -> Result<Arc<dyn Mode>>
pub async fn switch_mode(&self, mode_id: &str) -> Result<Arc<dyn Mode>>
Switch to a different mode
Sourcepub async fn context(&self) -> ModeContext
pub async fn context(&self) -> ModeContext
Get the current context
Sourcepub async fn update_context<F>(&self, f: F) -> Result<()>where
F: FnOnce(&mut ModeContext),
pub async fn update_context<F>(&self, f: F) -> Result<()>where
F: FnOnce(&mut ModeContext),
Update the context with a closure
Sourcepub fn mode_count(&self) -> usize
pub fn mode_count(&self) -> usize
Get the number of registered modes
Auto Trait Implementations§
impl Freeze for ModeManager
impl !RefUnwindSafe for ModeManager
impl Send for ModeManager
impl Sync for ModeManager
impl Unpin for ModeManager
impl !UnwindSafe for ModeManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more