harmos_packaging/
config.rs1use std::time::Duration;
20
21#[derive(Clone, Debug)]
34pub struct BuildSettings {
35 pub backend: BuildBackend,
36 pub manifest: std::path::PathBuf,
37 pub packages: Vec<String>,
38 pub target: Option<String>,
39 pub target_directory: Option<std::path::PathBuf>,
40 pub profile: BuildProfile,
41 pub timings: bool,
42 pub features: Vec<String>,
43 pub default_features: bool,
44}
45
46#[derive(Clone, Copy, Debug)]
47pub struct DevSettings {
48 pub debounce: Duration,
49}
50
51#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
52#[serde(rename_all = "snake_case")]
53pub enum BuildBackend {
54 Sidecar,
55 Guest,
56}
57
58#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
61#[serde(rename_all = "snake_case")]
62pub enum BuildProfile {
63 Dev,
64 Test,
65 Release,
66 Bench,
67}
68
69impl BuildProfile {
74 pub const fn name(self) -> &'static str {
75 match self {
76 Self::Dev => "dev",
77 Self::Test => "test",
78 Self::Release => "release",
79 Self::Bench => "bench",
80 }
81 }
82}
83
84impl std::str::FromStr for BuildProfile {
85 type Err = &'static str;
86 fn from_str(value: &str) -> Result<Self, Self::Err> {
87 match value {
88 "dev" => Ok(Self::Dev),
89 "test" => Ok(Self::Test),
90 "release" => Ok(Self::Release),
91 "bench" => Ok(Self::Bench),
92 _ => Err("profile must be dev, test, release or bench"),
93 }
94 }
95}
96
97impl Default for BuildSettings {
98 fn default() -> Self {
99 Self {
100 backend: BuildBackend::Sidecar,
101 manifest: "Cargo.toml".into(),
102 packages: Vec::new(),
103 target: None,
104 target_directory: None,
105 profile: BuildProfile::Dev,
106 timings: false,
107 features: Vec::new(),
108 default_features: true,
109 }
110 }
111}
112
113impl Default for DevSettings {
114 fn default() -> Self {
115 Self { debounce: Duration::from_millis(100) }
116 }
117}
118
119