crdt_migrate/lib.rs
1//! # crdt-migrate
2//!
3//! Transparent schema migrations for [`crdt-kit`](https://docs.rs/crdt-kit).
4//!
5//! When your data schema evolves between versions, `crdt-migrate` ensures that
6//! persisted data is automatically and transparently migrated — no downtime,
7//! no manual intervention, no data loss.
8//!
9//! ## How It Works
10//!
11//! 1. Every serialized CRDT is wrapped in a **version envelope** (3-byte header).
12//! 2. When data is loaded, the envelope version is compared to the current version.
13//! 3. If they differ, a **chain of migration steps** runs automatically.
14//! 4. Optionally, the migrated data is written back to storage.
15//!
16//! ## Key Concepts
17//!
18//! - **Lazy migration**: Data is migrated on read, not eagerly on startup.
19//! - **Deterministic**: Two devices migrating the same data produce identical results.
20//! - **Linear chain**: Migrations run v1→v2→v3→...→current, never skipping steps.
21//! - **Compiled in**: All migrations are embedded in the binary at compile time.
22
23#![cfg_attr(not(feature = "std"), no_std)]
24
25extern crate alloc;
26
27mod engine;
28mod envelope;
29mod schema;
30
31pub use engine::{MigrationConfig, MigrationEngine, MigrationError, MigrationStep};
32pub use envelope::{CrdtType, VersionedEnvelope, ENVELOPE_HEADER_SIZE, MAGIC_BYTE};
33pub use schema::Schema;
34
35// Re-export proc macros when the `macros` feature is enabled.
36#[cfg(feature = "macros")]
37pub use crdt_migrate_macros::{crdt_schema, migration};