Skip to main content

synwire_storage/
lib.rs

1//! Configurable persistent storage layout, project identity, and migration for Synwire.
2//!
3//! ## Overview
4//!
5//! This crate provides three core abstractions:
6//!
7//! - **[`StorageLayout`]**: computes all Synwire storage paths for a given
8//!   product name, respecting the platform data/cache directory conventions
9//!   (XDG on Linux, `~/Library/…` on macOS, `%APPDATA%` on Windows).
10//!
11//! - **[`RepoId`] + [`WorktreeId`]**: stable two-level project identity.
12//!   `RepoId` is derived from the Git first-commit hash (shared across clones
13//!   and worktrees).  `WorktreeId` further discriminates by worktree root path.
14//!
15//! - **[`StorageMigration`]**: per-subsystem schema version tracking and
16//!   incremental copy-then-swap migrations.
17//!
18//! - **[`ProjectRegistry`]**: global registry of indexed projects with
19//!   last-access timestamps and user tags.
20//!
21//! ## Quick start
22//!
23//! ```rust,no_run
24//! use synwire_storage::{StorageLayout, WorktreeId};
25//! use std::path::Path;
26//!
27//! let layout = StorageLayout::new("synwire").expect("storage layout");
28//! let worktree = WorktreeId::for_path(Path::new(".")).expect("worktree id");
29//!
30//! let index_path = layout.index_cache(&worktree);
31//! println!("Index cache: {}", index_path.display());
32//! ```
33
34#![forbid(unsafe_code)]
35#![warn(missing_docs)]
36
37pub mod concurrency;
38pub mod dependency_index;
39pub mod error;
40pub mod identity;
41pub mod layout;
42pub mod migration;
43pub mod registry;
44
45pub use concurrency::{atomic_write, ensure_wal_mode, open_wal_database};
46pub use dependency_index::{DependencyEntry, DependencyIndex, DependencyIndexError};
47pub use error::StorageError;
48pub use identity::{RepoId, WorktreeId};
49pub use layout::{StorageConfig, StorageLayout};
50pub use migration::{MigrationStep, NoOpMigrationStep, StorageMigration, VersionFile};
51pub use registry::{ProjectRegistry, RegistryEntry};