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
//! Block operations subsystem.
//!
//! Provides undo tree, change history, and atomic transactions.
//! Linux equivalent: Block device operations, journaling.
//!
//! # Design Principle
//!
//! Kernel provides mechanisms (pure Rust), drivers provide policies
//! (serialization). Snapshot provides accessors; file I/O is handled
//! by the driver layer.
//!
//! # Components
//!
//! - [`Transaction`]: Groups multiple edits for atomic undo/redo
//! - [`UndoTree`]: Branching undo history with cursor position tracking
//! - [`History`]: Change log with timestamps
//! - [`Snapshot`]: Buffer state capture for restore
//!
//! # Example
//!
//! ```
//! use reovim_kernel::api::v1::*;
//!
//! // Create an undo tree
//! let mut tree = UndoTree::new();
//!
//! // Record an edit with cursor positions
//! let edit = Edit::insert(Position::new(0, 0), "Hello");
//! tree.push(
//! vec![edit],
//! Position::new(0, 0), // cursor before
//! Position::new(0, 5), // cursor after
//! );
//!
//! // Undo returns edits to apply and cursor to restore
//! if let Some(result) = tree.undo() {
//! assert_eq!(result.cursor, Position::new(0, 0));
//! }
//! ```
pub use ;