diff --git a/src/infra/http_resolver.rs b/src/infra/http_resolver.rs index 7c9b981..0fa24f1 100644 --- a/src/infra/http_resolver.rs +++ b/src/infra/http_resolver.rs @@ -37,7 +37,11 @@ impl IpResolver for HttpIpResolver { let current_index = (start_index + offset) % n; let url = &self.urls[current_index]; - log::debug!("Attempting IP discovery with provider '{}' (index {})", url, current_index); + log::debug!( + "Attempting IP discovery with provider '{}' (index {})", + url, + current_index + ); let resp = self .agent diff --git a/src/infra/state_store.rs b/src/infra/state_store.rs index 8bf8294..c12e278 100644 --- a/src/infra/state_store.rs +++ b/src/infra/state_store.rs @@ -56,10 +56,11 @@ impl StateRepository for JsonStateRepository { source, })?; - file.write_all(&json_bytes).map_err(|source| StateError::Io { - path: tmp_path.display().to_string(), - source, - })?; + file.write_all(&json_bytes) + .map_err(|source| StateError::Io { + path: tmp_path.display().to_string(), + source, + })?; file.sync_all().map_err(|source| StateError::Io { path: tmp_path.display().to_string(), diff --git a/src/main.rs b/src/main.rs index 63ada30..41f2caa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,7 +86,11 @@ fn main() { std::process::exit(1); } }; - updaters.push(Box::new(DynuUpdater::new(&sub.domain, &credential, timeout))); + updaters.push(Box::new(DynuUpdater::new( + &sub.domain, + &credential, + timeout, + ))); } unknown => { log::error!("Unsupported DDNS provider: '{}'", unknown); @@ -105,7 +109,10 @@ fn main() { match service.run() { Ok(RunOutcome::NoChange { ip }) => { - log::info!("Execution complete: No IP change detected (current: {}).", ip); + log::info!( + "Execution complete: No IP change detected (current: {}).", + ip + ); std::process::exit(0); } Ok(RunOutcome::Updated { ip, subscribers }) => { diff --git a/src/plugins/dynu.rs b/src/plugins/dynu.rs index a1b896d..7bd24dc 100644 --- a/src/plugins/dynu.rs +++ b/src/plugins/dynu.rs @@ -48,7 +48,11 @@ impl DdnsUpdater for DynuUpdater { } fn update(&self, ip: Ipv4Addr) -> Result<(), UpdateError> { - log::info!("Updating Dynu record for domain '{}' to {}", self.domain, ip); + log::info!( + "Updating Dynu record for domain '{}' to {}", + self.domain, + ip + ); let resp = self .agent @@ -74,11 +78,7 @@ impl DdnsUpdater for DynuUpdater { })?; let trimmed = body.trim(); - log::debug!( - "Dynu response (status {}): '{}'", - status_code, - trimmed - ); + log::debug!("Dynu response (status {}): '{}'", status_code, trimmed); if !status_code.is_success() { return Err(UpdateError::NetworkError { diff --git a/src/service.rs b/src/service.rs index 64b57e1..8bb360e 100644 --- a/src/service.rs +++ b/src/service.rs @@ -82,7 +82,10 @@ impl IpMonitorService { ); if state.last_ip == Some(discovery.ip) { - log::info!("IP matches last successful IP ({}). No update needed.", discovery.ip); + log::info!( + "IP matches last successful IP ({}). No update needed.", + discovery.ip + ); // Persist the updated provider index so rotation continues state.last_provider_index = Some(discovery.provider_index); self.state_repo.save(&state)?; diff --git a/tests/domain_test.rs b/tests/domain_test.rs index 9bb5fa4..100d034 100644 --- a/tests/domain_test.rs +++ b/tests/domain_test.rs @@ -1,6 +1,8 @@ -use std::net::Ipv4Addr; -use ddns_monitor::domain::models::{HistoryEntry, IpDiscoveryResult, MonitorState, SubscriberResult}; +use ddns_monitor::domain::models::{ + HistoryEntry, IpDiscoveryResult, MonitorState, SubscriberResult, +}; use ddns_monitor::domain::validation::{is_valid_public_ipv4, next_provider_index}; +use std::net::Ipv4Addr; #[test] fn test_is_valid_public_ipv4() { diff --git a/tests/dynu_plugin_test.rs b/tests/dynu_plugin_test.rs index 1166b49..e35c114 100644 --- a/tests/dynu_plugin_test.rs +++ b/tests/dynu_plugin_test.rs @@ -90,12 +90,8 @@ fn test_dynu_updater_server_error() { .create(); let endpoint = format!("{}/nic/update", server.url()); - let updater = DynuUpdater::with_endpoint( - "test.example.com", - "pass", - endpoint, - Duration::from_secs(2), - ); + let updater = + DynuUpdater::with_endpoint("test.example.com", "pass", endpoint, Duration::from_secs(2)); let res = updater.update(Ipv4Addr::new(198, 51, 100, 5)); assert!(res.is_err()); diff --git a/tests/service_test.rs b/tests/service_test.rs index b6c020d..5fde3af 100644 --- a/tests/service_test.rs +++ b/tests/service_test.rs @@ -1,6 +1,4 @@ -use ddns_monitor::domain::errors::{ - HistoryError, ResolveError, StateError, UpdateError, -}; +use ddns_monitor::domain::errors::{HistoryError, ResolveError, StateError, UpdateError}; use ddns_monitor::domain::models::{HistoryEntry, IpDiscoveryResult, MonitorState}; use ddns_monitor::domain::traits::{DdnsUpdater, HistoryRepository, IpResolver, StateRepository}; use ddns_monitor::service::{IpMonitorService, RunOutcome}; @@ -255,7 +253,9 @@ fn test_all_failed_preserves_old_last_ip() { vec![Box::new(updater1), Box::new(updater2)], ); - let outcome = service.run().expect("service run returns all failed status"); + let outcome = service + .run() + .expect("service run returns all failed status"); match outcome { RunOutcome::AllFailed { ip, subscribers } => { assert_eq!(ip, new_ip);