Skip to main content
← dvs documentation Rust API reference

dvs/files/
types.rs

1use std::fmt;
2
3use serde::{Deserialize, Serialize};
4
5/// Outcome of an add or get operation.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
7#[serde(rename_all = "lowercase")]
8pub enum Outcome {
9    /// File was copied to/from storage.
10    Copied,
11    /// File was already present (no action needed).
12    Present,
13}
14
15#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)]
16#[serde(rename_all = "lowercase")]
17pub enum Status {
18    /// Local file not tracked in dvs
19    Untracked,
20    /// Local file exists and matches stored version.
21    Current,
22    /// Metadata exists but local file is missing.
23    Absent,
24    /// Local file matches the baseline, while metadata points to another version.
25    Stale,
26    /// Local file differs from current metadata and from the local baseline.
27    Modified,
28    /// Local file differs from metadata, but no baseline exists to explain why.
29    Unsynced,
30}
31
32impl fmt::Display for Status {
33    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34        match self {
35            Status::Current => write!(f, "current"),
36            Status::Absent => write!(f, "absent"),
37            Status::Stale => write!(f, "stale"),
38            Status::Modified => write!(f, "modified"),
39            Status::Unsynced => write!(f, "unsynced"),
40            Status::Untracked => write!(f, "untracked"),
41        }
42    }
43}