Module fs_interface

Module fs_interface 

Source
Expand description

High-level filesystem interface for Heroforge repositories.

FsInterface provides a filesystem-like API with staging directory support. All writes go to staging first, with background commits to the database.

§Architecture

┌─────────────────────────────────────────────────────────────────┐
│                      FsInterface (sync API)                     │
│  - RwLock<StagingState>                                         │
│  - Author name (set at initialization)                          │
│  - All read/write operations acquire appropriate locks          │
└─────────────────────────────────────────────────────────────────┘
                              │
          ┌───────────────────┴───────────────────┐
          │                                       │
          ▼                                       ▼
┌─────────────────────┐                 ┌─────────────────────────┐
│   Staging Directory │                 │    Commit Thread        │
│                     │                 │    (background)         │
└─────────────────────┘                 └─────────────────────────┘

§Example

use heroforge_core::Repository;
use heroforge_core::fs::FsInterface;
use std::sync::Arc;

let repo = Arc::new(Repository::open_rw("project.forge")?);
let fs = FsInterface::new(repo, "developer@example.com")?;

// Write goes to staging (fast)
fs.write_file("config.json", b"{}")?;

// Read checks staging first, then database
let content = fs.read_file("config.json")?;

// Partial update (read-modify-write pattern)
fs.write_at("data.bin", 100, b"updated")?;

// Force immediate commit (normally auto-commits every 1 minute)
fs.commit()?;

Structs§

FsInterface
High-level filesystem interface with staging support.

Enums§

FsInterfaceStatus
Status of the FsInterface