Skip to main content

wire/answer/
scanning.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4// Copyright (c) 2026 2youg1 and the sprawling contributors
5
6//! Whether real-time scanning stands in front of the city directory's
7//! writes, as the doctor page reads it (`crates/wire/spec/Answer/Doctor.lean`
8//! D25).
9//!
10//! Arm for arm the shape of `bin::doctor::scanning::Scanning`, because
11//! the page says exactly what the terminal says; paths and commands
12//! travel as rendered strings, since `PathBuf` and `&'static str` are
13//! no wire types.
14
15use serde::{Deserialize, Serialize};
16
17/// What this machine says about scanning in front of the city's
18/// directory.
19#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
20#[serde(rename_all = "snake_case")]
21#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
22pub enum DoctorScanning {
23    /// macOS and Linux: Dev Drive and Defender's exclusions are Windows
24    /// features, and neither platform scans every write synchronously.
25    DoesNotApply,
26    /// The thread that asked stopped before it answered.
27    Stopped,
28    Read {
29        /// The directory judged, spelled the way mount points are.
30        city: String,
31        drive: DoctorDrive,
32        exclusion: DoctorExclusion,
33    },
34}
35
36/// Whether the city's volume is a Dev Drive.
37#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
38#[serde(rename_all = "snake_case")]
39#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
40pub enum DoctorDrive {
41    /// A trusted Dev Drive: scanned after a write rather than before.
42    Trusted,
43    /// A Dev Drive that is not trusted, scanned like any other volume.
44    Untrusted {
45        volume: String,
46    },
47    /// No Dev Drive at all.
48    Not {
49        volume: String,
50        file_system: String,
51    },
52    Untold {
53        why: DoctorUntold,
54    },
55}
56
57/// Whether one of Defender's exclusions holds the city.
58#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
59#[serde(rename_all = "snake_case")]
60#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
61pub enum DoctorExclusion {
62    /// `under` is the excluded path that holds it.
63    Inside {
64        under: String,
65    },
66    Outside,
67    Untold {
68        why: DoctorUntold,
69    },
70}
71
72/// Why a question about scanning has no answer here. `command` is the
73/// tool as a person reads its name, such as `fsutil devdrv query`.
74#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
75#[serde(rename_all = "snake_case")]
76#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
77pub enum DoctorUntold {
78    /// No disk this machine lists holds the path.
79    NoDisk,
80    /// Defender shows its exclusions only to an administrator.
81    AdminOnly,
82    /// The tool answered in words that are not read here, such as the
83    /// system's own language.
84    Unread {
85        command: String,
86    },
87    Failed {
88        command: String,
89        code: Option<i32>,
90    },
91    Unstarted {
92        command: String,
93    },
94    Unanswered {
95        command: String,
96        stopping: Option<String>,
97    },
98}