Skip to content

Commit 8e3a87c

Browse files
authored
Merge pull request #28 from NotAShelf/optimize-daemon
daemon: optimize
2 parents 6e2d5b3 + 32422f2 commit 8e3a87c

File tree

11 files changed

+184
-564
lines changed

11 files changed

+184
-564
lines changed

Cargo.lock

Lines changed: 14 additions & 161 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ dirs = "6.0"
1313
clap = { version = "4.0", features = ["derive"] }
1414
num_cpus = "1.16"
1515
ctrlc = "3.4"
16-
notify = { version = "8.0.0", features = ["serde"] }
1716
chrono = "0.4"
1817
log = "0.4"
1918
env_logger = "0.11"
19+
thiserror = "2.0"
20+
anyhow = "1.0"

src/battery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub fn set_battery_charge_thresholds(start_threshold: u8, stop_threshold: u8) ->
7474
// Validate thresholds using `BatteryChargeThresholds`
7575
let thresholds =
7676
BatteryChargeThresholds::new(start_threshold, stop_threshold).map_err(|e| match e {
77-
crate::config::types::ConfigError::ValidationError(msg) => {
77+
crate::config::types::ConfigError::Validation(msg) => {
7878
ControlError::InvalidValueError(msg)
7979
}
8080
_ => ControlError::InvalidValueError(format!("Invalid battery threshold values: {e}")),

src/config/load.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn load_config_from_path(specific_path: Option<&str>) -> Result<AppConfig, C
2626
if path.exists() {
2727
return load_and_parse_config(path);
2828
}
29-
return Err(ConfigError::IoError(std::io::Error::new(
29+
return Err(ConfigError::Io(std::io::Error::new(
3030
std::io::ErrorKind::NotFound,
3131
format!("Specified config file not found: {}", path.display()),
3232
)));
@@ -80,10 +80,9 @@ pub fn load_config_from_path(specific_path: Option<&str>) -> Result<AppConfig, C
8080

8181
/// Load and parse a configuration file
8282
fn load_and_parse_config(path: &Path) -> Result<AppConfig, ConfigError> {
83-
let contents = fs::read_to_string(path).map_err(ConfigError::IoError)?;
83+
let contents = fs::read_to_string(path).map_err(ConfigError::Io)?;
8484

85-
let toml_app_config =
86-
toml::from_str::<AppConfigToml>(&contents).map_err(ConfigError::TomlError)?;
85+
let toml_app_config = toml::from_str::<AppConfigToml>(&contents).map_err(ConfigError::Toml)?;
8786

8887
// Handle inheritance of values from global to profile configs
8988
let mut charger_profile = toml_app_config.charger.clone();

src/config/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pub mod load;
22
pub mod types;
3-
pub mod watcher;
43

54
pub use load::*;
65
pub use types::*;

0 commit comments

Comments
 (0)