use std::fmt;
use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct Variable {
pub key: String,
pub environment_scope: String,
pub value: String,
pub description: Option<String>,
pub masked: bool,
pub protected: bool,
pub raw: bool,
pub variable_type: VariableType,
}
impl Variable {
#[must_use]
pub fn is_same(&self, other: &Self) -> bool {
self.key == other.key && self.environment_scope == other.environment_scope
}
}
impl fmt::Display for Variable {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} ({})", self.key, self.environment_scope)
}
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum VariableType {
#[default]
EnvVar,
File,
}
impl VariableType {
#[must_use]
pub fn is_default(&self) -> bool {
*self == Self::default()
}
}