Skip to main content

cynos_storage/
lib.rs

1//! Cynos Storage - Storage layer for Cynos in-memory database.
2//!
3//! This crate provides the storage layer including:
4//!
5//! - `RowStore`: Row storage with index maintenance
6//! - `TableCache`: Multi-table cache management
7//! - `Journal`: Change tracking for transactions
8//! - `Transaction`: Transaction management with rollback support
9//! - `ConstraintChecker`: Constraint validation
10//! - `LockManager`: Concurrent access control
11//!
12//! # Example
13//!
14//! ```rust
15//! use cynos_storage::{TableCache, Transaction};
16//! use cynos_core::schema::TableBuilder;
17//! use cynos_core::{DataType, Row, Value};
18//!
19//! // Create a cache and table
20//! let mut cache = TableCache::new();
21//! let schema = TableBuilder::new("users")
22//!     .unwrap()
23//!     .add_column("id", DataType::Int64)
24//!     .unwrap()
25//!     .add_column("name", DataType::String)
26//!     .unwrap()
27//!     .add_primary_key(&["id"], false)
28//!     .unwrap()
29//!     .build()
30//!     .unwrap();
31//! cache.create_table(schema).unwrap();
32//!
33//! // Use a transaction
34//! let mut tx = Transaction::begin();
35//! let row = Row::new(1, vec![Value::Int64(1), Value::String("Alice".into())]);
36//! tx.insert(&mut cache, "users", row).unwrap();
37//! tx.commit().unwrap();
38//!
39//! assert_eq!(cache.get_table("users").unwrap().len(), 1);
40//! ```
41
42#![no_std]
43
44extern crate alloc;
45
46pub mod cache;
47pub mod constraint;
48pub mod journal;
49pub mod lock;
50pub mod row_store;
51pub mod transaction;
52
53pub use cache::TableCache;
54pub use constraint::ConstraintChecker;
55pub use journal::{Journal, JournalEntry, TableDiff};
56pub use lock::{LockManager, LockType};
57pub use row_store::{BTreeIndexStore, HashIndexStore, IndexStore, RowStore};
58pub use transaction::{Transaction, TransactionId, TransactionState};