1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! Command provider trait for module command registration.
//!
//! This trait allows modules to provide command handlers for registration
//! without modifying the kernel Module trait. It maintains kernel purity
//! by keeping driver-layer concerns in the driver layer.
//!
//! # Architecture
//!
//! ```text
//! Kernel Layer Driver Layer
//! ┌──────────────────┐ ┌─────────────────────┐
//! │ Module trait │ │ CommandProvider │
//! │ (identity, deps) │ │ (handlers) │
//! └──────────────────┘ └─────────────────────┘
//! │ │
//! └───────────┬───────────────────┘
//! │
//! ▼
//! ┌───────────────┐
//! │ EditorModule │ implements both
//! └───────────────┘
//! ```
//!
//! # Example
//!
//! ```ignore
//! use reovim_driver_command::{CommandHandler, CommandProvider};
//!
//! struct EditorModule;
//!
//! impl CommandProvider for EditorModule {
//! fn command_handlers(&self) -> Vec<Box<dyn CommandHandler>> {
//! vec![
//! Box::new(CursorUp),
//! Box::new(CursorDown),
//! // ...
//! ]
//! }
//! }
//! ```
use CommandHandler;
/// Trait for modules that provide command handlers.
///
/// Modules implement this trait to register their command handlers.
/// The runner queries this trait during module loading to wire commands.
///
/// # Design
///
/// This trait is separate from the kernel's `Module` trait to maintain
/// kernel purity. The kernel defines module identity and lifecycle;
/// command handlers are a driver-layer concern.
///
/// # Thread Safety
///
/// The trait requires `Send + Sync` because modules may be accessed
/// from multiple threads during command registration and execution.
///
/// # Example
///
/// ```ignore
/// use reovim_driver_command::{CommandHandler, CommandProvider};
///
/// struct EditorModule;
///
/// impl CommandProvider for EditorModule {
/// fn command_handlers(&self) -> Vec<Box<dyn CommandHandler>> {
/// vec![
/// Box::new(CursorUp),
/// Box::new(CursorDown),
/// Box::new(DeleteChar),
/// ]
/// }
/// }
/// ```