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 store;
25pub mod walk;
26
27pub use cache::{
28 check_manifest_integrity, check_snapshot_integrity, flush_cache, load_cached_manifest,
29 verify_cache, CacheError, CacheReport,
30};
31pub use excludes::{
32 expand_excludes, ExcludeError, ExcludeMatcher, ExpandedExclude, FollowMode,
33 COMMON_EXCLUDE_DIRS, SYSTEM_EXCLUDE_DIRS,
34};
35pub use manifest::{Manifest, ManifestEntry, ParseError, PathType};
36pub use merkle::{
37 directory_checksum, snapshot_id, Blake3Hasher, Blake3KeyedHasher, Hasher, Md5Hasher,
38 Sha256Hasher,
39};
40pub use store::{manifest_path, object_path, Store, StoreError, MANIFESTS_DIR, OBJECTS_DIR};
41pub use walk::{walk, PathMode, WalkError, WalkOptions};