embedded_controls/
lib.rs

1//! Embedded controls library is based on [switch-hal](https://crates.io/crates/switch-hal)
2//! that allows to handle primitive controls like [`DebounceInput`](crate::DebouncedInput),
3//! [`Encoder`](crate::Encoder).
4
5#![no_std]
6
7mod debounced_input;
8mod encoder;
9mod error;
10
11pub mod macros;
12
13pub use debounced_input::{DebouncedInput, DebouncedInputConfig, DebouncedInputEvent};
14pub use encoder::{Encoder, EncoderConfig, EncoderEvent};
15pub use error::Error;
16
17/// Represents a control, such as debounced input, button, encoder and etc.
18pub trait Control {
19    type Event;
20    type Error;
21
22    /// Update a control and return an current event or error after update.
23    fn update(&mut self) -> Result<Self::Event, Self::Error>;
24}