embedded_menu/interaction/
programmed.rs

1use core::marker::PhantomData;
2
3use crate::interaction::{InputAdapter, InputAdapterSource, InputResult, Interaction};
4
5#[derive(Clone, Copy)]
6pub struct Programmed;
7
8impl<R> InputAdapterSource<R> for Programmed {
9    type InputAdapter = ProgrammedAdapter<R>;
10
11    fn adapter(&self) -> Self::InputAdapter {
12        ProgrammedAdapter {
13            _marker: PhantomData,
14        }
15    }
16}
17
18pub struct ProgrammedAdapter<R> {
19    _marker: PhantomData<R>,
20}
21
22impl<R> Clone for ProgrammedAdapter<R> {
23    fn clone(&self) -> Self {
24        *self
25    }
26}
27
28impl<R> Copy for ProgrammedAdapter<R> {}
29
30impl<R> InputAdapter for ProgrammedAdapter<R> {
31    type Input = Interaction<R>;
32    type Value = R;
33    type State = ();
34
35    fn handle_input(
36        &self,
37        _state: &mut Self::State,
38        action: Self::Input,
39    ) -> InputResult<Self::Value> {
40        InputResult::from(action)
41    }
42}