anni_workspace/
state.rs

1use serde::Serialize;
2use std::path::PathBuf;
3use uuid::Uuid;
4
5#[derive(Debug, Serialize)]
6pub struct WorkspaceAlbum {
7    pub album_id: Uuid,
8    #[serde(flatten)]
9    pub state: WorkspaceAlbumState,
10}
11
12pub struct UntrackedWorkspaceAlbum {
13    pub album_id: Uuid,
14    pub path: PathBuf,
15    /// For album with only one disc, the disc directory is not required.
16    /// Users can choose to put all tracks in the album directory.
17    /// This is called `simplified` album structure.
18    pub simplified: bool,
19    pub discs: Vec<UntrackedWorkspaceDisc>,
20}
21
22pub struct UntrackedWorkspaceDisc {
23    pub index: usize,
24    pub path: PathBuf,
25    pub cover: PathBuf,
26    pub tracks: Vec<PathBuf>,
27}
28
29/// State of album directory in workspace
30#[derive(Debug, Serialize)]
31#[serde(tag = "type", content = "path")]
32#[serde(rename_all = "kebab-case")]
33pub enum WorkspaceAlbumState {
34    // Normal states
35    /// `Untracked` album directory.
36    /// Controlled part of the album directory is empty.
37    Untracked(PathBuf),
38    /// `Committed` album directory.
39    /// Controlled part of the album directory is not empty, and User part contains symlinks to the actual file.
40    Committed(PathBuf),
41    /// `Published` album directory.
42    /// Controlled part of the album directory is not empty, and `.publish` file exists.
43    Published,
44
45    // Error states
46    /// User part of an album exists, but controlled part does not exist, or the symlink is broken.
47    Dangling(PathBuf),
48    /// User part of an album does not exist, and controlled part is empty.
49    Garbage,
50}