RKTK API Docs RKTK Home Repo

rktk/hooks/
mod.rs

1//! Hooks are used to customize the behavior of the application.
2
3use interface::*;
4
5pub mod interface;
6pub use empty_hooks::create_empty_hooks;
7
8/// Hooks that can be passed to [`crate::task::start`] function.
9/// See earch trait's documentation for more information.
10pub struct Hooks<CH: CommonHooks, MH: MasterHooks, SH: SlaveHooks, RH: RgbHooks> {
11    pub common: CH,
12    pub master: MH,
13    pub slave: SH,
14    pub rgb: RH,
15}
16
17/// Collection of sender/receiver that can be used with hooks.
18pub mod channels {
19    pub use crate::task::channels::*;
20}
21
22/// Collection of empty hooks and utility functions.
23pub mod empty_hooks {
24    use super::{
25        Hooks, MasterHooks, SlaveHooks,
26        interface::{CommonHooks, RgbHooks},
27    };
28
29    pub struct EmptyCommonHooks;
30    impl CommonHooks for EmptyCommonHooks {}
31
32    pub struct EmptyMasterHooks;
33    impl MasterHooks for EmptyMasterHooks {}
34
35    pub struct EmptySlaveHooks;
36    impl SlaveHooks for EmptySlaveHooks {}
37
38    pub struct EmptyRgbHooks;
39    impl RgbHooks for EmptyRgbHooks {}
40
41    pub const fn create_empty_hooks()
42    -> Hooks<EmptyCommonHooks, EmptyMasterHooks, EmptySlaveHooks, EmptyRgbHooks> {
43        Hooks {
44            common: EmptyCommonHooks,
45            master: EmptyMasterHooks,
46            slave: EmptySlaveHooks,
47            rgb: EmptyRgbHooks,
48        }
49    }
50}