pub enum State<I> {
Down(I),
Pressed(I),
Up(I),
Held(I),
Released,
Unknown,
}
Expand description
Represents current button state.
State machine diagram:
ⓘ
Down => Pressed | Released
Pressed => Held => Up
Up => Released | Down
Held => Released
Released => Down
Unknown => Down | Released
Variants§
Down(I)
The button has been just pressed, so it is in down position.
Pressed(I)
Debounced press.
Up(I)
The button has been just released, so it is in up position.
Held(I)
The button is being held.
Released
Fully released state, idle.
Unknown
Initial state.
Implementations§
Source§impl<I: PartialEq> State<I>
impl<I: PartialEq> State<I>
Sourcepub fn is_pressed(&self) -> bool
pub fn is_pressed(&self) -> bool
Sourcepub fn is_released(&self) -> bool
pub fn is_released(&self) -> bool
Sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
Trait Implementations§
impl<I: Copy> Copy for State<I>
impl<I: Eq> Eq for State<I>
impl<I> StructuralPartialEq for State<I>
Auto Trait Implementations§
impl<I> Freeze for State<I>where
I: Freeze,
impl<I> RefUnwindSafe for State<I>where
I: RefUnwindSafe,
impl<I> Send for State<I>where
I: Send,
impl<I> Sync for State<I>where
I: Sync,
impl<I> Unpin for State<I>where
I: Unpin,
impl<I> UnwindSafe for State<I>where
I: UnwindSafe,
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