1use std::fmt;
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
7pub struct Variable {
8 pub key: String,
9 pub environment_scope: String,
10 pub value: String,
11 pub description: Option<String>,
12 pub masked: bool,
13 pub protected: bool,
14 pub raw: bool,
15 pub variable_type: VariableType,
16}
17
18impl Variable {
19 #[must_use]
22 pub fn is_same(&self, other: &Self) -> bool {
23 self.key == other.key && self.environment_scope == other.environment_scope
24 }
25}
26
27impl fmt::Display for Variable {
28 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29 write!(f, "{} ({})", self.key, self.environment_scope)
30 }
31}
32
33#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
35#[serde(rename_all = "snake_case")]
36pub enum VariableType {
37 #[default]
38 EnvVar,
39 File,
40}
41
42impl VariableType {
43 #[must_use]
44 pub fn is_default(&self) -> bool {
45 *self == Self::default()
46 }
47}