-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add appstore.timeout and refresh_interval
- Loading branch information
1 parent
b83796e
commit 06ad410
Showing
5 changed files
with
73 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
appstore: | ||
refresh_interval_ms: 86400 | ||
timeout_ms: 500 | ||
keys: | ||
- crypto wallet | ||
apps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use std::env; | ||
|
||
use config::{Config, ConfigError, Environment, File}; | ||
use serde::Deserialize; | ||
|
||
#[derive(Debug, Deserialize, Clone)] | ||
#[allow(unused)] | ||
pub struct SettingsOperator { | ||
pub appstore: OperatorAppStore, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Clone)] | ||
#[allow(unused)] | ||
pub struct OperatorAppStore { | ||
pub refresh_interval_ms: u64, | ||
pub timeout_ms: u64, | ||
pub keys: Vec<String>, | ||
pub apps: Vec<OperatorAppStoreApp>, | ||
pub languages: Vec<OperatorAppStoreLanguage>, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Clone)] | ||
#[allow(unused)] | ||
pub struct OperatorAppStoreApp { | ||
pub name: String, | ||
pub id: u64, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Clone)] | ||
#[allow(unused)] | ||
pub struct OperatorAppStoreLanguage { | ||
pub name: String, | ||
pub code: String, | ||
} | ||
|
||
impl SettingsOperator { | ||
pub fn new() -> Result<Self, ConfigError> { | ||
let current_dir = env::current_dir().unwrap(); | ||
let setting_path = current_dir.join("SettingsOperator.yaml"); | ||
let s = Config::builder() | ||
.add_source(File::from(setting_path)) | ||
.add_source(Environment::with_prefix("").prefix_separator("").separator("_")) | ||
.build()?; | ||
s.try_deserialize() | ||
} | ||
} |