Compare commits
2 Commits
62a3dc80b8
...
119e9eef22
Author | SHA1 | Date |
---|---|---|
Dmitry Belyaev | 119e9eef22 | |
Dmitry Belyaev | a516c777c3 |
File diff suppressed because it is too large
Load Diff
|
@ -10,15 +10,15 @@ async-stream = "0.3.3"
|
|||
clap = { version = "4.0.2", features = ["derive"] }
|
||||
ctrlc = "3.2.3"
|
||||
fast-socks5 = "0.8.1"
|
||||
flexi_logger = { version = "0.23.3", features = ["specfile_without_notification", "async"] }
|
||||
flexi_logger = { version = "0.25.5", features = ["specfile_without_notification", "async"] }
|
||||
log = "0.4.17"
|
||||
serde = { version = "1.0.145", features = ["derive"] }
|
||||
serde_derive = "1.0.145"
|
||||
tokio = { version = "1.24.1", features = ["io-std", "net", "rt-multi-thread", "macros"] }
|
||||
tokio-stream = "0.1.11"
|
||||
tokio-util = "0.7.4"
|
||||
toml = "0.5.9"
|
||||
windows-service = "0.5.0"
|
||||
toml = "0.7.4"
|
||||
windows-service = "0.6.0"
|
||||
|
||||
[profile.release]
|
||||
opt-level = 3
|
||||
|
|
|
@ -66,11 +66,12 @@ impl Default for Config {
|
|||
impl Config {
|
||||
const FILENAME: &'static str = "config.toml";
|
||||
fn read<P: AsRef<Path>>(path: P) -> Result<Self, String> {
|
||||
let data = fs::read(path).map_err(|e| format!("can't read config: {:?}", e))?;
|
||||
toml::from_slice(&data).map_err(|e| format!("can't parse config: {:?}", e))
|
||||
let data = fs::read_to_string(path).map_err(|e| format!("can't read config: {:?}", e))?;
|
||||
toml::from_str(&data).map_err(|e| format!("can't parse config: {:?}", e))
|
||||
}
|
||||
fn write<P: AsRef<Path>>(&self, path: P) -> Result<(), String> {
|
||||
let data = toml::to_vec(&self).map_err(|e| format!("can't serialize config: {:?}", e))?;
|
||||
let data = toml::to_string_pretty(&self)
|
||||
.map_err(|e| format!("can't serialize config: {:?}", e))?;
|
||||
fs::write(path, &data).map_err(|e| format!("can't write config: {:?}", e))
|
||||
}
|
||||
fn file_location() -> Result<PathBuf, String> {
|
||||
|
|
Loading…
Reference in New Issue