sapphire_framework_sync/report.rs
1//! What a scan, an apply or a fetch did.
2
3use crate::entry::Entry;
4
5/// Why a path was not synced on this replica.
6#[derive(Clone, Debug, PartialEq, Eq)]
7pub enum SkipReason {
8 /// Excluded by the built-in rule or `.sapphireignore`.
9 Ignored,
10 TooLarge {
11 len: u64,
12 max: u64,
13 },
14 /// The local OS cannot represent the path.
15 Unrepresentable,
16 /// Another path differing only in case is already on disk.
17 CaseCollision {
18 other: String,
19 },
20 Symlink,
21 /// Not available locally and the content source could not provide the bytes.
22 ContentUnavailable,
23 /// The local path holds something this replica has not recorded (a directory, a
24 /// symlink, or a file it cannot hash within the size cap), so it is left untouched.
25 Occupied,
26 /// A per-path I/O error kept this path from being reconciled; sync continues with
27 /// other paths. The message is the underlying error's `Display`.
28 Io(String),
29}
30
31#[derive(Clone, Debug, PartialEq, Eq)]
32pub struct Skipped {
33 pub path: String,
34 pub reason: SkipReason,
35}
36
37#[derive(Clone, Debug, PartialEq, Eq)]
38pub struct Conflict {
39 pub path: String,
40 pub copy_path: String,
41}
42
43/// Why a replica refuses to scan or apply.
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45pub enum PauseReason {
46 RootMissing,
47 MarkerMissing,
48}
49
50/// Effects of one `scan`, `apply` or `fetch_missing` call.
51#[derive(Clone, Debug, Default, PartialEq, Eq)]
52pub struct Report {
53 /// Local writes recorded, including conflict copies.
54 pub recorded: Vec<Entry>,
55 /// Number of path-state changes committed.
56 pub changed: usize,
57 pub conflicts: Vec<Conflict>,
58 pub skipped: Vec<Skipped>,
59}
60
61#[derive(Clone, Debug, PartialEq, Eq)]
62pub enum ScanOutcome {
63 Scanned(Report),
64 Paused(PauseReason),
65}