Skip to main content

ryo_storage/
lib.rs

1#![warn(missing_docs)]
2//! RYO Storage - Persistent storage and transaction log
3//!
4//! This crate provides:
5//! - **Storage**: Session persistence and replay
6//! - **TxLog**: Transaction logging for undo/redo and replay
7//!
8//! # Architecture
9//!
10//! ```text
11//! ┌─────────────────────────────────────────────────────────────────────────┐
12//! │  Layer 1: Mutation (Functional Layer)                                   │
13//! │  - trait Mutation { apply(), describe(), ... }                          │
14//! └─────────────────────────────────────────────────────────────────────────┘
15//!                             ↓ generates at execution time
16//! ┌─────────────────────────────────────────────────────────────────────────┐
17//! │  Layer 2: MutationRecord (Recording Layer)                              │
18//! │  - Serializable record of each mutation                                 │
19//! │  - Contains: MutationSpec + StateRef(pre) + StateRef(post)              │
20//! └─────────────────────────────────────────────────────────────────────────┘
21//!                             ↓ references
22//! ┌─────────────────────────────────────────────────────────────────────────┐
23//! │  Layer 3: StateStore (State Layer)                                      │
24//! │  - Content-addressed storage for file states                            │
25//! │  - Immutable: StateRef = hash of content                                │
26//! └─────────────────────────────────────────────────────────────────────────┘
27//! ```
28//!
29//! # Usage
30//!
31//! ```ignore
32//! use ryo_storage::{RyoStorage, TxLog, TxLogger};
33//!
34//! // Create storage
35//! let mut storage = RyoStorage::global()?;
36//! storage.ensure_init()?;
37//!
38//! // Start logging
39//! let logger = TxLogger::start(project_path, file_count);
40//! logger.log_mutation("Rename", "foo → bar", 3);
41//! let log = logger.finish();
42//!
43//! // Save session
44//! let session_id = storage.dump(&log)?;
45//!
46//! // Load and replay
47//! let loaded = storage.load(&session_id)?;
48//! ```
49
50pub mod storage;
51pub mod txlog;
52pub mod uuid_storage;
53
54// Re-export storage types
55pub use storage::{
56    AutoSaveLogger, CliConfig, ConfigError, Format, FormatError, FormatResult, GlobalConfig,
57    ProjectIndex, ProjectMeta, RyoStorage, ServerConfig, SessionFormat, SessionIndex, SessionMeta,
58    StateRef, StateStore, StorageError, StorageResult, TxLogMode,
59};
60
61// Re-export txlog types
62pub use txlog::{
63    MutationRecord, ReplayAnalysis, ReplayEngine, ReplayError, ReplayMode, ReplayResult, TxAction,
64    TxEntry, TxLog, TxLogger, TxSummary,
65};
66
67// Re-export UUID storage types
68pub use uuid_storage::FileUuidStorage;