DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/WindServiceAdapters/
WindConfigurationService.rs1use std::sync::Arc;
8
9use CommonLibrary::Configuration::{
10 ConfigurationProvider::ConfigurationProvider,
11 DTO::{ConfigurationOverridesDTO::ConfigurationOverridesDTO, ConfigurationTarget::ConfigurationTarget},
12};
13
14pub struct Struct {
15 pub(super) provider:Arc<dyn ConfigurationProvider>,
16}
17
18impl Struct {
19 pub fn new(provider:Arc<dyn ConfigurationProvider>) -> Self { Self { provider } }
20
21 pub async fn get_value(&self, key:String) -> Result<serde_json::Value, String> {
22 self.provider
23 .GetConfigurationValue(Some(key.to_string()), ConfigurationOverridesDTO::default())
24 .await
25 .map_err(|e| e.to_string())
26 }
27
28 pub async fn update_value(&self, key:String, value:serde_json::Value) -> Result<(), String> {
29 self.provider
30 .UpdateConfigurationValue(
31 key,
32 value,
33 ConfigurationTarget::User,
34 ConfigurationOverridesDTO::default(),
35 None,
36 )
37 .await
38 .map_err(|e| e.to_string())
39 }
40}