tutti_types/
lib.rs

1use std::{
2    collections::{BTreeMap, HashMap},
3    fmt::Display,
4    path::PathBuf,
5};
6
7use serde::{Deserialize, Serialize};
8
9#[derive(Debug, Eq, PartialEq, Hash, Clone, Serialize, Deserialize)]
10pub struct ProjectId(pub PathBuf);
11
12impl Display for ProjectId {
13    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14        write!(f, "{}", self.0.display())
15    }
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
19pub struct Project {
20    pub version: u32,
21    pub id: ProjectId,
22    pub services: BTreeMap<String, Service>,
23}
24
25#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
26pub enum Restart {
27    Always,
28    #[default]
29    Never,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
33pub struct Service {
34    pub cmd: Vec<String>,
35    pub cwd: Option<PathBuf>,
36    pub env: Option<HashMap<String, String>>,
37    pub deps: Vec<String>,
38    pub healthcheck: Option<()>, // TODO
39    pub restart: Restart,
40}