Skip to main content

Event

Enum Event 

Source
pub enum Event<D: TimeDuration, I: TimeInstant<Duration = D>> {
    Press {
        at: I,
    },
    Release {
        duration: D,
        click_follows: bool,
    },
    Click {
        count: u8,
    },
    Hold {
        clicks_before: u8,
        level: u8,
    },
}
Expand description

A button event produced by the state machine.

Variants§

§

Press

The button was pressed. Fires immediately on press edge. at is the timestamp of the press, identical to what crate::ButtHead::press_instant returns during the pressed state.

Fields

§at: I
§

Release

The button was released. duration is the total time it was held. click_follows is true when a Event::Click will follow (the release ends a click gesture), and false when it ends a hold gesture.

Fields

§duration: D
§click_follows: bool
§

Click

A complete click gesture (press + release, no hold). count starts at 1. Fires once after click_timeout expires with no further press. A double-click produces a single Click { count: 2 }.

Fields

§count: u8
§

Hold

The button is being held. Fires repeatedly at a configured interval. clicks_before is the number of clicks that preceded this hold (0 = plain hold, 1 = click+hold, 2 = double-click+hold, …). level increments on each repeat (0 = first hold event, 1 = second, …).

Fields

§clicks_before: u8
§level: u8

Trait Implementations§

Source§

impl<D: Clone + TimeDuration, I: Clone + TimeInstant<Duration = D>> Clone for Event<D, I>

Source§

fn clone(&self) -> Event<D, I>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D: Debug + TimeDuration, I: Debug + TimeInstant<Duration = D>> Debug for Event<D, I>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<D: PartialEq + TimeDuration, I: PartialEq + TimeInstant<Duration = D>> PartialEq for Event<D, I>

Source§

fn eq(&self, other: &Event<D, I>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<D: Copy + TimeDuration, I: Copy + TimeInstant<Duration = D>> Copy for Event<D, I>

Source§

impl<D: Eq + TimeDuration, I: Eq + TimeInstant<Duration = D>> Eq for Event<D, I>

Source§

impl<D: TimeDuration, I: TimeInstant<Duration = D>> StructuralPartialEq for Event<D, I>

Auto Trait Implementations§

§

impl<D, I> Freeze for Event<D, I>
where I: Freeze, D: Freeze,

§

impl<D, I> RefUnwindSafe for Event<D, I>

§

impl<D, I> Send for Event<D, I>
where I: Send, D: Send,

§

impl<D, I> Sync for Event<D, I>
where I: Sync, D: Sync,

§

impl<D, I> Unpin for Event<D, I>
where I: Unpin, D: Unpin,

§

impl<D, I> UnsafeUnpin for Event<D, I>
where I: UnsafeUnpin, D: UnsafeUnpin,

§

impl<D, I> UnwindSafe for Event<D, I>
where I: UnwindSafe, D: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.