pub struct TimedKeyEvent {
    pub key: Key,
    pub duration_since_start: Duration,
    pub event_type: KeyEventType,
}Expand description
A single key event to be replayed by dispatch_key_events_async.
See crate::dispatch_key_events for details of the key event type and the event timing.
For example, a key press like this:
Key1: _________/"""""""""""""""\\___________
               ^               ^--- key released
               `------------------- key pressed
      |<------>|  <-- duration_since_start (50ms)
      |<---------------------->| duration_since_start (100ms)would be described with a sequence of two TimedKeyEvents (pseudo-code):
[
   { Key1,  50ms, PRESSED  },
   { Key1, 100ms, RELEASED },
]This is not overly useful in the case of a single key press, but is useful to model multiple concurrent keypresses, while allowing an arbitrary interleaving of key events.
Consider a more complicated timing diagram like this one:
Key1: _________/"""""""""""""""\\_____________
Key2: ____/"""""""""""""""\\__________________
Key3: ______/"""""""""""""""\\________________
Key4: _____________/"""""""""""""""\\_________
Key5: ________________ __/""""""\\____________
Key6: ________/""""""\\_______________________It then becomes obvious how modeling individual events allows us to express this interaction.
Furthermore anchoring duration_since_start to the beginning of the key sequence (instead of,
for example, specifying the duration of each key press) gives a common time reference and makes
it fairly easy to express the intended key interaction in terms of a TimedKeyEvent sequence.
Fields§
§key: KeyThe [input::Key] which changed state.
duration_since_start: DurationThe duration of time,  relative to the start of the key event sequence that this TimedKeyEvent
is part of, at which this event happened at.
event_type: KeyEventTypeThe type of state change that happened to key.  Was it pressed, released or something
else.
Implementations§
Source§impl TimedKeyEvent
 
impl TimedKeyEvent
Sourcepub fn new(
    key: Key,
    type_: KeyEventType,
    duration_since_start: Duration,
) -> Self
 
pub fn new( key: Key, type_: KeyEventType, duration_since_start: Duration, ) -> Self
Creates a new TimedKeyEvent to inject into the input pipeline.  key is
the key to be pressed (using Fuchsia HID-like encoding), type_ is the
event type (Pressed, or Released etc), and duration_since_start is the
duration since the start of the entire event sequence that the key event
should be scheduled at.
Sourcepub fn vec<'de, D>(deserializer: D) -> Result<Vec<TimedKeyEvent>, D::Error>where
    D: Deserializer<'de>,
 
pub fn vec<'de, D>(deserializer: D) -> Result<Vec<TimedKeyEvent>, D::Error>where
    D: Deserializer<'de>,
Deserializes a vector of TimedKeyEvent.
A custom deserializer is used because Vec<_> does not work
with serde, and the TimedKeyEvent has constituents that don’t
have a derived serde representation.
See: https://github.com/serde-rs/serde/issues/723#issuecomment-382501277
Trait Implementations§
Source§impl Clone for TimedKeyEvent
 
impl Clone for TimedKeyEvent
Source§fn clone(&self) -> TimedKeyEvent
 
fn clone(&self) -> TimedKeyEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TimedKeyEvent
 
impl Debug for TimedKeyEvent
Source§impl PartialEq for TimedKeyEvent
 
impl PartialEq for TimedKeyEvent
impl Eq for TimedKeyEvent
impl StructuralPartialEq for TimedKeyEvent
Auto Trait Implementations§
impl Freeze for TimedKeyEvent
impl RefUnwindSafe for TimedKeyEvent
impl Send for TimedKeyEvent
impl Sync for TimedKeyEvent
impl Unpin for TimedKeyEvent
impl UnwindSafe for TimedKeyEvent
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
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
    D: ResourceDialect,
 
impl<T, D> Encode<Ambiguous1, D> for Twhere
    D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
    D: ResourceDialect,
 
impl<T, D> Encode<Ambiguous2, D> for Twhere
    D: ResourceDialect,
§impl<T> InstanceFromServiceTransport<T> for T
 
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
 
fn from_service_transport(handle: T) -> T
T to [Self]§impl<T> IntoAny for T
 
impl<T> IntoAny for T
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 more