reovim_kernel/api/v1.rs
1//! Stable Kernel API v1.
2//!
3//! Linux equivalent: `include/linux/`
4//!
5//! This module provides the stable public interface for drivers and modules.
6//! All types exported here are covered by semver guarantees within the v1.x series.
7//!
8//! # Stability Guarantee
9//!
10//! - Breaking changes require a new major version (v2)
11//! - New APIs may be added in minor versions
12//! - Patch versions contain only bug fixes
13//!
14//! # Usage
15//!
16//! ```ignore
17//! use reovim_kernel::api::v1::*;
18//!
19//! // Check API compatibility
20//! check_api_version(Version::new(1, 0, 0))?;
21//!
22//! // Use kernel types
23//! let bus = EventBus::new();
24//! pr_info!("kernel initialized");
25//! ```
26
27// ============================================================================
28// Version
29// ============================================================================
30
31pub use super::version::{
32 API_VERSION, API_VERSION_STR, Version, VersionError, VersionErrorKind, check_api_version,
33 is_compatible,
34};
35
36// ============================================================================
37// Context
38// ============================================================================
39
40pub use super::context::{KernelContext, ModuleContext};
41
42// ============================================================================
43// Memory Management (mm/)
44// ============================================================================
45
46pub use crate::mm::{
47 Buffer, BufferId, Cursor, Edit, Position, TabId, TextDimensions, WindowId, delete_end,
48 text_dimensions, transform_position,
49};
50
51// Selection types
52pub use crate::mm::{Selection, SelectionMode};
53
54// Snapshot for lock-free buffer access
55pub use crate::mm::BufferSnapshot;
56
57// Word boundary detection
58pub use crate::mm::{
59 CharKind, WordType, char_kind, next_word_end, next_word_start, word_bounds, word_end,
60 word_start,
61};
62
63// Delimiter matching
64pub use crate::mm::{find_delimiter_pair, find_matching_delimiter};
65
66// Line caching
67pub use crate::mm::LineCache;
68
69// Background task scheduler
70pub use crate::mm::{
71 RequestPriority, SaturationRequest, SaturatorConfig, SaturatorHandle, spawn_saturator,
72};
73
74// ============================================================================
75// IPC (ipc/)
76// ============================================================================
77
78// Event types
79pub use crate::ipc::{
80 CacheKind, CacheUpdated, DEFAULT_TIMEOUT, DispatchResult, DynEvent, Event, EventBus,
81 EventResult, EventScope, EventSender, HandlerContext, ScopeId, Subscription, SubscriptionId,
82 TargetedEvent,
83};
84
85// Event definitions (kernel and driver events)
86pub use crate::ipc::events;
87
88// Channel types
89pub use crate::ipc::{
90 BoundedReceiver, BoundedSender, OneshotReceiver, OneshotSender, Receiver, RecvError, SendError,
91 Sender, TryRecvError, TrySendError, bounded, channel, oneshot,
92};
93
94// ============================================================================
95// Core Primitives (core/)
96// ============================================================================
97
98// Jumplist
99pub use crate::core::{JumpEntry, Jumplist, MAX_JUMPLIST_SIZE};
100
101// Motion
102pub use crate::core::{Direction, LinePosition, Motion, MotionEngine, WordBoundary};
103
104// Text Objects
105pub use crate::core::{TextObject, TextObjectEngine};
106
107// Registers
108pub use crate::core::{HistoryRing, Register, RegisterBank, RegisterContent, YankType};
109
110// Marks
111pub use crate::core::{Mark, MarkBank, MarkResult, SpecialMark};
112
113// Options
114pub use crate::core::{
115 ConstraintError, OptionConstraint, OptionError, OptionRegistry, OptionScope, OptionScopeId,
116 OptionSpec, OptionValue, SetResult,
117};
118
119// Config
120pub use crate::core::{Config, ConfigError, ConfigPaths, ConfigValue};
121
122// Mode and Command identity types
123// Note: OperatorId moved to modules/vim (Epic #385 - operators are vim-specific policy)
124pub use crate::core::{CommandId, CursorStyle, Mode, ModeId, ModeStack};
125
126// ============================================================================
127// Block Operations (block/)
128// ============================================================================
129
130pub use crate::block::{
131 EditOrigin, History, HistoryEntry, Snapshot, Transaction, UndoNode, UndoResult, UndoTree,
132};
133
134// BufferManager is MECHANISM (pure storage interface, like Linux page cache)
135// It stays in kernel - no I/O policy, just storage lifecycle
136pub use super::buffer_manager::{BufferError, BufferManager};
137
138// Note: UndoManager, WindowManager, and policy traits (Operator,
139// KeymapProvider, CommandHandler) have been moved out of the kernel to follow
140// the "mechanism vs policy" principle. See lib/drivers/ for driver-level traits.
141
142// ============================================================================
143// Scheduler (sched/)
144// ============================================================================
145
146pub use crate::sched::{
147 BoxedTask,
148 // Configuration constants
149 DEFAULT_BATCH_SIZE,
150 DEFAULT_MAX_TIMERS,
151 DEFAULT_PRIORITY_QUEUE_CAPACITY,
152 DEFAULT_WORK_QUEUE_CAPACITY,
153 Executor,
154 PRIORITY_QUEUE_DEFAULT_CAPACITY,
155 Priority,
156 PriorityQueue,
157 Runtime,
158 RuntimeCommand,
159 RuntimeConfig,
160 RuntimeState,
161 RuntimeStats,
162 Task,
163 TaskId,
164 TaskState,
165 // Timer types
166 TimerConfig,
167 TimerHandle,
168 TimerId,
169 TimerWheel,
170 WORK_QUEUE_DEFAULT_CAPACITY,
171 WORK_QUEUE_MAX_CAPACITY,
172 WorkQueue,
173};
174
175// ============================================================================
176// Logging (printk/)
177// ============================================================================
178
179// Types and functions
180pub use crate::printk::{
181 Level, Logger, NopLogger, ParseLevelError, Record, RecordBuilder, SetLoggerError, flush,
182 logger, set_logger,
183};
184
185// Internal function needed by macros (hidden from docs)
186#[doc(hidden)]
187pub use crate::printk::__log;
188
189// Macros (re-export from crate root for unified access)
190pub use crate::{pr_debug, pr_err, pr_info, pr_trace, pr_warn};
191
192// ============================================================================
193// Module System (api/)
194// ============================================================================
195
196pub use super::module::{
197 CommandRegistration, EventHandlerRegistration, KeybindingRegistration, Module, ModuleError,
198 ModuleId, ModuleInfo, ModuleProbe, ModuleState, ProbeResult, RegistrationFlags,
199};
200
201// ============================================================================
202// Service Registry (api/service.rs)
203// ============================================================================
204
205pub use super::service::{MultiServiceRegistry, Service, ServiceKey, ServiceRegistry};
206
207// Note: SyntaxHighlight trait has been moved to lib/drivers/syntax/
208
209// ============================================================================
210// Sync Primitives (from arch)
211// ============================================================================
212
213pub use reovim_arch::sync::{
214 ArcSwap, Condvar, Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard,
215};
216
217// ============================================================================
218// Debug (api/debug.rs)
219// ============================================================================
220
221pub use super::debug::{
222 // Snapshot types
223 KernelStateSnapshot,
224 MarkSnapshot,
225 MarksSnapshot,
226 ModeStackSnapshot,
227 RegisterSnapshot,
228 RegistersSnapshot,
229 YankTypeSnapshot,
230 // Snapshot functions
231 snapshot_kernel_state,
232 snapshot_marks,
233 snapshot_mode_stack,
234 snapshot_registers,
235};
236
237// ============================================================================
238// Profiling (debug/profiler.rs)
239// ============================================================================
240
241#[allow(deprecated)]
242pub use crate::debug::{
243 // Profiler trait and types
244 NopProfiler,
245 ProfileGuard,
246 ProfileScope,
247 Profiler,
248 SetProfilerError,
249 SpanData,
250 SpanId,
251 // Global profiler functions
252 profiler,
253 set_profiler,
254};
255
256// Profiling macros (re-export from crate root)
257pub use crate::{profile, profile_counter, profile_fn, profile_histogram, profile_scope};
258
259// Metrics registry (for direct histogram/counter access)
260pub use crate::debug::{Counter, Histogram, MetricsRegistry, MetricsSnapshot, metrics};
261
262// ============================================================================
263// Panic Handling (panic/)
264// ============================================================================
265
266pub use crate::panic::{
267 // Report
268 CrashReport,
269 // Handler
270 DebugContext,
271 // Recovery
272 RecoverySnapshot,
273 UnsavedBuffer,
274 cleanup_old_recovery_files,
275 generate_crash_report,
276 install_panic_handler,
277 is_handler_installed,
278 list_recovery_files,
279 recovery_dir,
280 save_buffer_for_recovery,
281 set_debug_context_callback,
282 set_recovery_callback,
283};
284
285// ============================================================================
286// Tests
287// ============================================================================