pub enum TimerCommand<T> {
Set {
id: T,
duration: Duration,
},
Kill {
id: T,
},
}Expand description
A command to set or kill a timer.
Timer commands are part of the Response returned by state machine
transitions. The runtime is responsible for translating these into
actual platform timer operations.
§Set vs Kill
| Variant | When to use |
|---|---|
Set | Start a new timer or reset an existing one (e.g., restart the debounce window on every incoming event) |
Kill | Cancel a pending timer that is no longer needed (e.g., a key was released before the chord window closed) |
Set with an ID that already has an active timer resets that
timer — it does not create a second concurrent timer for the same ID.
Kill for an ID with no active timer is a silent no-op.
Variants§
Set
Start (or restart) a timer with the given ID and duration.
If a timer with the same ID is already active, it is reset to the new duration. Use this to implement “restart the window on every new event” patterns such as debounce or inactivity timeouts.
Fields
id: TTimer identifier.
duration: DurationDuration after which TimedStateMachine::on_timeout should be called.
Kill
Stop an active timer.
If no timer with this ID is active, this is a no-op. Use this when a subsequent event makes the pending timeout irrelevant (e.g., the other chord key was released, so the window is moot).
Fields
id: TTimer identifier to stop.
Trait Implementations§
Source§impl<T: Clone> Clone for TimerCommand<T>
impl<T: Clone> Clone for TimerCommand<T>
Source§fn clone(&self) -> TimerCommand<T>
fn clone(&self) -> TimerCommand<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Debug> Debug for TimerCommand<T>
impl<T: Debug> Debug for TimerCommand<T>
Source§impl<T: Hash> Hash for TimerCommand<T>
impl<T: Hash> Hash for TimerCommand<T>
Source§impl<T: PartialEq> PartialEq for TimerCommand<T>
impl<T: PartialEq> PartialEq for TimerCommand<T>
Source§fn eq(&self, other: &TimerCommand<T>) -> bool
fn eq(&self, other: &TimerCommand<T>) -> bool
self and other values to be equal, and is used by ==.