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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//! Empty session handler mechanism.
//!
//! Provides the trait for handling empty sessions (no buffers).
//! Modules implement this trait to define policy for what happens
//! when a session starts with no buffers.
//!
//! # Linux Kernel Parallel
//!
//! Like a driver's `probe()` function that initializes a device,
//! `EmptySessionHandler::handle()` initializes an empty session.
use Path;
/// Action to take when session is empty.
///
/// Returned by [`EmptySessionHandler::handle()`] to indicate what
/// action the runner should take.
/// Context provided to empty session handlers.
///
/// Contains read-only information about the session state.
/// Handlers cannot mutate state directly; they return an action
/// that the runner executes.
/// Handler for empty session state.
///
/// Modules implement this trait to define what happens when a session
/// has no buffers. The runner calls handlers in priority order until
/// one returns an action other than [`EmptySessionAction::None`].
///
/// # Priority Convention
///
/// - 0-50: Core handlers (system-level)
/// - 100: Default module priority
/// - 200+: Late/fallback handlers
///
/// # Example
///
/// ```ignore
/// use reovim_driver_session::{
/// EmptySessionHandler, EmptySessionContext, EmptySessionAction
/// };
///
/// pub struct ScratchBufferHandler;
///
/// impl EmptySessionHandler for ScratchBufferHandler {
/// fn handle(&self, _ctx: &EmptySessionContext) -> EmptySessionAction {
/// EmptySessionAction::CreateBuffer {
/// name: None,
/// content: String::new(),
/// }
/// }
///
/// fn priority(&self) -> u32 { 100 }
///
/// fn id(&self) -> &'static str { "defaults:scratch-buffer" }
///
/// fn description(&self) -> &'static str {
/// "Create empty scratch buffer on startup"
/// }
/// }
/// ```