pub enum Cmd<M> {
None,
Quit,
Batch(Vec<Cmd<M>>),
Sequence(Vec<Cmd<M>>),
Msg(M),
Tick(Duration),
Log(String),
Task(TaskSpec, Box<dyn FnOnce() -> M + Send>),
SaveState,
RestoreState,
SetMouseCapture(bool),
SetTickStrategy(Box<dyn TickStrategy>),
}Expand description
Commands represent side effects to be executed by the runtime.
Commands are returned from init() and update() to trigger
actions like quitting, sending messages, or scheduling ticks.
Variants§
None
No operation.
Quit
Quit the application.
Batch(Vec<Cmd<M>>)
Execute multiple commands as a batch (currently sequential).
Sequence(Vec<Cmd<M>>)
Execute commands sequentially.
Msg(M)
Send a message to the model.
Tick(Duration)
Schedule a tick after a duration.
Log(String)
Write a log message to the terminal output.
This writes to the scrollback region in inline mode, or is ignored/handled appropriately in alternate screen mode. Safe to use with the One-Writer Rule.
Task(TaskSpec, Box<dyn FnOnce() -> M + Send>)
Execute a blocking operation on a background thread.
When effect queue scheduling is enabled, tasks are enqueued and executed in Smith-rule order on a dedicated worker thread. Otherwise the closure runs on a spawned thread immediately. The return value is sent back as a message to the model.
SaveState
Save widget state to the persistence registry.
Triggers a flush of the state registry to the storage backend. No-op if persistence is not configured.
RestoreState
Restore widget state from the persistence registry.
Triggers a load from the storage backend and updates the cache. No-op if persistence is not configured. Returns a message via callback if state was successfully restored.
SetMouseCapture(bool)
Toggle mouse capture at runtime.
Instructs the terminal session to enable or disable mouse event capture. No-op in test simulators.
SetTickStrategy(Box<dyn TickStrategy>)
Replace the tick strategy at runtime.
Takes ownership of a boxed strategy. Use when switching from one
strategy to another (e.g., Uniform → Predictive after loading
persisted transition data).
Implementations§
Source§impl<M> Cmd<M>
impl<M> Cmd<M>
Sourcepub fn log(msg: impl Into<String>) -> Cmd<M>
pub fn log(msg: impl Into<String>) -> Cmd<M>
Create a log command.
The message will be sanitized and written to the terminal log (scrollback). A newline is appended if not present.
Sourcepub fn task<F>(f: F) -> Cmd<M>
pub fn task<F>(f: F) -> Cmd<M>
Create a background task command.
The closure runs on a spawned thread (or the effect queue worker when
scheduling is enabled). When it completes, the returned message is
sent back to the model’s update().
Sourcepub fn task_with_spec<F>(spec: TaskSpec, f: F) -> Cmd<M>
pub fn task_with_spec<F>(spec: TaskSpec, f: F) -> Cmd<M>
Create a background task command with explicit scheduling metadata.
Sourcepub fn task_weighted<F>(weight: f64, estimate_ms: f64, f: F) -> Cmd<M>
pub fn task_weighted<F>(weight: f64, estimate_ms: f64, f: F) -> Cmd<M>
Create a background task command with explicit weight and estimate.
Sourcepub fn task_named<F>(name: impl Into<String>, f: F) -> Cmd<M>
pub fn task_named<F>(name: impl Into<String>, f: F) -> Cmd<M>
Create a named background task command.
Sourcepub fn set_tick_strategy(strategy: impl TickStrategy + 'static) -> Cmd<M>
pub fn set_tick_strategy(strategy: impl TickStrategy + 'static) -> Cmd<M>
Replace the active tick strategy at runtime.
Use when switching strategies (e.g., Uniform → Predictive after
loading persisted transition data).
Sourcepub fn save_state() -> Cmd<M>
pub fn save_state() -> Cmd<M>
Create a save state command.
Triggers a flush of the state registry to the storage backend. No-op if persistence is not configured.
Sourcepub fn restore_state() -> Cmd<M>
pub fn restore_state() -> Cmd<M>
Create a restore state command.
Triggers a load from the storage backend. No-op if persistence is not configured.
Sourcepub fn set_mouse_capture(enabled: bool) -> Cmd<M>
pub fn set_mouse_capture(enabled: bool) -> Cmd<M>
Create a mouse capture toggle command.
Instructs the runtime to enable or disable mouse event capture on the underlying terminal session.
Trait Implementations§
Auto Trait Implementations§
impl<M> Freeze for Cmd<M>where
M: Freeze,
impl<M> !RefUnwindSafe for Cmd<M>
impl<M> Send for Cmd<M>where
M: Send,
impl<M> !Sync for Cmd<M>
impl<M> Unpin for Cmd<M>where
M: Unpin,
impl<M> UnsafeUnpin for Cmd<M>where
M: UnsafeUnpin,
impl<M> !UnwindSafe for Cmd<M>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().