Mountain/ApplicationState/DTO/
MergedConfigurationStateDTO.rs1#![allow(non_snake_case, non_camel_case_types)]
7
8use serde::{Deserialize, Serialize};
9use serde_json::Value;
10
11#[derive(Serialize, Deserialize, Clone, Debug, Default)]
15#[serde(rename_all = "PascalCase")]
16pub struct MergedConfigurationStateDTO {
17 pub Data:Value,
18}
19
20impl MergedConfigurationStateDTO {
21 pub fn Create(Data:Value) -> Self { Self { Data } }
23
24 pub fn GetValue(&self, Section:Option<&str>) -> Value {
27 if let Some(Path) = Section {
28 Path.split('.')
29 .try_fold(&self.Data, |Node, Key| Node.get(Key))
30 .unwrap_or(&Value::Null)
31 .clone()
32 } else {
33 self.Data.clone()
34 }
35 }
36}