quadrature_encoder/
mode.rs

1mod linear;
2mod rotary;
3
4use core::marker::PhantomData;
5use quadrature_decoder::Change;
6
7pub use self::{
8    linear::{Linear, LinearMovement},
9    rotary::{Rotary, RotaryMovement},
10};
11
12pub trait Movement: From<Change> + Eq {
13    /// Returns the direction of `self`, flipped.
14    fn flipped(self) -> Self;
15}
16
17/// The mode of physical operation of a quadrature encoder.
18pub trait OperationMode {
19    /// The mode's type of movement.
20    type Movement: Movement;
21}
22
23/// A marker trait for initializing drivers in a specific mode.
24/// Inspired by https://github.com/esp-rs/esp-hal
25pub trait PollMode {}
26
27/// Driver initialized in blocking mode.
28#[derive(Debug)]
29pub struct Blocking;
30
31/// Driver initialized in async mode.
32#[derive(Debug)]
33pub struct Async(PhantomData<*const ()>);
34
35impl crate::PollMode for Blocking {}
36impl crate::PollMode for Async {}