dux_core/cache/metadata.rs
1use std::path::PathBuf;
2use std::time::SystemTime;
3
4use serde::{Deserialize, Serialize};
5
6/// Current cache format version - increment when format changes
7pub const CACHE_VERSION: u32 = 2;
8
9/// Magic bytes identifying a DUX cache file
10pub const CACHE_MAGIC: [u8; 4] = *b"DUXC";
11
12/// Metadata stored with cached tree
13#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct CacheMetadata {
15 /// Cache format version
16 pub version: u32,
17 /// Root path that was scanned
18 pub root_path: PathBuf,
19 /// When the scan was performed
20 pub scan_time: SystemTime,
21 /// Modification time of root directory at scan time (for quick invalidation)
22 pub root_mtime: SystemTime,
23 /// Total size of scanned tree
24 pub total_size: u64,
25 /// Number of nodes in tree
26 pub node_count: usize,
27 /// Scan configuration used
28 pub config: CachedScanConfig,
29}
30
31/// Scan configuration that affects cache validity
32#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
33pub struct CachedScanConfig {
34 /// Whether symlinks were followed during scan
35 pub follow_symlinks: bool,
36 /// Whether scan stayed on same filesystem
37 pub same_filesystem: bool,
38 /// Maximum depth that was scanned
39 pub max_depth: Option<usize>,
40}