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 exists but differs from stored version.
25    Unsynced,
26}
27
28impl fmt::Display for Status {
29    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30        match self {
31            Status::Current => write!(f, "current"),
32            Status::Absent => write!(f, "absent"),
33            Status::Unsynced => write!(f, "unsynced"),
34            Status::Untracked => write!(f, "untracked"),
35        }
36    }
37}