Skip to main content

argyph_fs/
lib.rs

1#![forbid(unsafe_code)]
2
3mod hash;
4mod language;
5mod path;
6mod walker;
7mod watcher;
8
9use camino::Utf8Path;
10use std::time::SystemTime;
11
12pub use hash::{hash_file, hash_files_parallel, Blake3Hash};
13pub use language::Language;
14pub use walker::{IgnoreWalker, PollingWalker};
15pub use watcher::{ChangeKind, ChangedPath, FileWatcher, FsWatcher, PollingWatcher};
16
17/// Walks a repository root, yielding [`FileEntry`] records with path, hash,
18/// detected language, size, and modification time. Honors `.gitignore` and
19/// related exclusion files.
20pub trait Walker {
21    fn walk(&self, root: &Utf8Path) -> impl Iterator<Item = FileEntry>;
22}
23
24/// A file discovered during repository walking.
25#[derive(Debug, Clone)]
26pub struct FileEntry {
27    /// Path relative to the walk root.
28    pub path: camino::Utf8PathBuf,
29    /// BLAKE3 content hash.
30    pub hash: Blake3Hash,
31    /// Detected language, or `None` if unrecognized.
32    pub language: Option<Language>,
33    /// File size in bytes.
34    pub size: u64,
35    /// Last modification time (falls back to [`SystemTime::UNIX_EPOCH`] if
36    /// the platform cannot determine it).
37    pub modified: SystemTime,
38}