Polish: extract src/lib.rs so bins reuse a proper library crate
Build with clawstor cache / Cargo build (clawstor-cached) (pull_request) Failing after 2s

Historically every bin (claw-store, claw-cargo, claw-fuse)
re-declared the same 13-line 'mod ...' block at its own root.
Working but fragile — a new bin (or a new module) needed edits
in N+1 places and stayed one edit-slip away from silently
dropping something.

Now: src/lib.rs owns the shared module tree. Cargo.toml gets a
[lib] entry so cargo picks it up. claw_fuse.rs migrated as the
proof-of-concept — 13 mod lines → 4 use lines.

claw-store + claw-cargo bins still use their internal 'mod ...'
blocks and 'crate::...' paths — migrating them is mechanical
but noisy; deferred to a follow-on so this PR stays reviewable.
Both bins + tests continue to build unchanged.

387 tests pass.
This commit is contained in:
Omar Sobh
2026-07-14 13:14:14 -07:00
parent 7a3c04bed7
commit 0e5e5982d8
3 changed files with 43 additions and 21 deletions
+7 -21
View File
@@ -24,27 +24,13 @@ use std::ffi::OsStr;
use std::path::PathBuf;
use std::time::{Duration, UNIX_EPOCH};
// Same module tree as main.rs / claw_cargo.rs — bin-only crate,
// so we redeclare the mods here. Only `cluster::blob` is actually
// used from this bin.
mod actions;
mod cargo_init;
mod cluster;
mod config;
mod daemon;
mod head_watch;
mod hot;
mod manifest;
mod restore;
mod serve;
mod snapshot;
mod sync;
mod zfs;
use cluster::blob::{BlobId, BlobStore};
use cluster::refs::RefStore;
use cluster::snapshot::SnapshotStore;
use cluster::tags::TagStore;
// Polish (2026-07-14): lib split. Bin pulls from the library crate
// rather than re-declaring every internal module. Adds/removes to
// the module tree happen in exactly one place (src/lib.rs).
use claw_store::cluster::blob::{BlobId, BlobStore};
use claw_store::cluster::refs::RefStore;
use claw_store::cluster::snapshot::SnapshotStore;
use claw_store::cluster::tags::TagStore;
const TTL: Duration = Duration::from_secs(1);