Skip to main content

snapdir_core/
lib.rs

1//! snapdir core library.
2//!
3//! Manifest format, BLAKE3 merkle hashing, store trait, directory walk, and
4//! cache live here. Per the library-purity principle, this crate performs no
5//! terminal I/O and reads no `$HOME`/config/environment for behavior: inputs
6//! arrive as parameters and errors surface as typed [`thiserror`] enums.
7//!
8//! The [`manifest`] module owns the frozen manifest line format
9//! (`PATH_TYPE PERMISSIONS CHECKSUM SIZE PATH`) and its (de)serialization. The
10//! [`merkle`] module owns the directory checksum rule (sort + dedup + concat +
11//! re-hash of the direct children's checksums), the snapshot id
12//! ([`snapshot_id`] — BLAKE3 of the comment-stripped manifest text, distinct
13//! from the root directory checksum), and the [`Hasher`] abstraction with its
14//! in-process [`Blake3Hasher`], keyed [`Blake3KeyedHasher`]
15//! (`SNAPDIR_MANIFEST_CONTEXT`), [`Md5Hasher`] and [`Sha256Hasher`]
16//! (`--checksum-bin`) implementations. The [`excludes`] module owns the
17//! `%system%`/`%common%` expansion, the `grep -E -v` matcher, and the
18//! follow/no-follow option semantics.
19
20pub mod cache;
21pub mod excludes;
22pub mod manifest;
23pub mod merkle;
24pub mod progress;
25pub mod store;
26pub mod walk;
27
28pub use cache::{
29    check_manifest_integrity, check_snapshot_integrity, flush_cache, load_cached_manifest,
30    verify_cache, CacheError, CacheReport,
31};
32pub use excludes::{
33    expand_excludes, ExcludeError, ExcludeMatcher, ExpandedExclude, FollowMode,
34    COMMON_EXCLUDE_DIRS, SYSTEM_EXCLUDE_DIRS,
35};
36pub use manifest::{Manifest, ManifestEntry, ParseError, PathType};
37pub use merkle::{
38    directory_checksum, snapshot_id, Blake3Hasher, Blake3KeyedHasher, Hasher, Md5Hasher,
39    Sha256Hasher,
40};
41pub use progress::{Meter, MeterSnapshot, Phase};
42pub use store::{manifest_path, object_path, Store, StoreError, MANIFESTS_DIR, OBJECTS_DIR};
43pub use walk::{walk, walk_with_meter, PathMode, WalkError, WalkOptions};