Skip to main content

Button

Trait Button 

Source
pub trait Button<R: ButtonRole>: Send {
    // Required methods
    fn wait_for_pressed<'a>(
        &'a mut self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>;
    fn is_pressed(&self) -> bool;
}
Expand description

Async interface for waiting on a button press and querying its state.

Required Methods§

Source

fn wait_for_pressed<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>

Wait until the button transitions to the pressed state.

The returned future resolves once a debounced press is detected.

Source

fn is_pressed(&self) -> bool

Returns true if the button is currently pressed.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§