use indexmap::IndexMap;
#[doc(hidden)]
#[derive(Debug, Clone, PartialEq)]
pub struct PlaceholderValue {
pub(crate) path: String,
pub(crate) optional: bool,
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum HoconValue {
Object(IndexMap<String, HoconValue>),
Array(Vec<HoconValue>),
Scalar(ScalarValue),
#[doc(hidden)]
Placeholder(PlaceholderValue),
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ScalarType {
String,
Number,
Boolean,
Null,
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct ScalarValue {
pub raw: String,
pub value_type: ScalarType,
}
impl ScalarValue {
pub fn new(raw: String, value_type: ScalarType) -> Self {
Self { raw, value_type }
}
pub fn string(raw: String) -> Self {
Self {
raw,
value_type: ScalarType::String,
}
}
pub fn null() -> Self {
Self {
raw: "null".to_string(),
value_type: ScalarType::Null,
}
}
pub fn boolean(value: bool) -> Self {
Self {
raw: if value { "true" } else { "false" }.to_string(),
value_type: ScalarType::Boolean,
}
}
pub fn number(raw: String) -> Self {
Self {
raw,
value_type: ScalarType::Number,
}
}
}