diff --git a/src/controller.rs b/src/controller.rs index c0cb8e2..3b4ed7e 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -5,15 +5,19 @@ use std::future::Future; /// Asynchronous context listener task. /// -/// Listens for changes in [`Controller::Context`] and updates the -/// corresponding hardware state accordingly, e.g. LEDs, screens, +/// Listens for changes in [`ControllerTypes::Context`] and updates +/// the corresponding hardware state accordingly, e.g. LEDs, screens, /// or motorized jog wheels and faders. pub type BoxedControllerTask = Box + Send + 'static>; -pub trait Controller { +pub trait ControllerTypes { type Context; type InputEvent; type ControlAction; +} + +pub trait Controller { + type Types: ControllerTypes; /// Attach a context listener task. /// @@ -24,7 +28,10 @@ pub trait Controller { /// /// Controllers that don't need a task may return `None`. #[must_use] - fn attach_context_listener(&mut self, context: &Self::Context) -> Option; + fn attach_context_listener( + &mut self, + context: &::Context, + ) -> Option; /// Map a generic input event into a control action. /// @@ -35,5 +42,8 @@ pub trait Controller { /// is unsupported and should be ignored or if it only affects the internal /// state then `None` could be returned. #[must_use] - fn map_input_event(&mut self, event: Self::InputEvent) -> Option; + fn map_input_event( + &mut self, + event: ::InputEvent, + ) -> Option<::ControlAction>; } diff --git a/src/lib.rs b/src/lib.rs index f44e299..e67833d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,7 +31,7 @@ use std::{ }; mod controller; -pub use self::controller::{BoxedControllerTask, Controller}; +pub use self::controller::{BoxedControllerTask, Controller, ControllerTypes}; pub mod devices;