style: format codebase with cargo fmt

Apply standard rustfmt formatting across src and tests crates:
- Wrap log macro arguments in http_resolver, main, dynu plugin, and service
- Format method chaining in JsonStateRepository
- Reorder and group imports and format test assertions in tests suite
This commit is contained in:
kiskaadee committed 2026-10-28 10:59:59 -05:00
1 parent 28fac178b5
commit 7c198c981c
8 files changed
+36 -23

No files matched your search

+5 -1
View File
@@ -37,7 +37,11 @@ impl IpResolver for HttpIpResolver {
let current_index = (start_index + offset) % n; let current_index = (start_index + offset) % n;
let url = &self.urls[current_index]; 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 let resp = self
.agent .agent
+2 -1
View File
@@ -56,7 +56,8 @@ impl StateRepository for JsonStateRepository {
source, source,
})?; })?;
file.write_all(&json_bytes).map_err(|source| StateError::Io { file.write_all(&json_bytes)
.map_err(|source| StateError::Io {
path: tmp_path.display().to_string(), path: tmp_path.display().to_string(),
source, source,
})?; })?;
+9 -2
View File
@@ -86,7 +86,11 @@ fn main() {
std::process::exit(1); 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 => { unknown => {
log::error!("Unsupported DDNS provider: '{}'", unknown); log::error!("Unsupported DDNS provider: '{}'", unknown);
@@ -105,7 +109,10 @@ fn main() {
match service.run() { match service.run() {
Ok(RunOutcome::NoChange { ip }) => { 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); std::process::exit(0);
} }
Ok(RunOutcome::Updated { ip, subscribers }) => { Ok(RunOutcome::Updated { ip, subscribers }) => {
+6 -6
View File
@@ -48,7 +48,11 @@ impl DdnsUpdater for DynuUpdater {
} }
fn update(&self, ip: Ipv4Addr) -> Result<(), UpdateError> { 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 let resp = self
.agent .agent
@@ -74,11 +78,7 @@ impl DdnsUpdater for DynuUpdater {
})?; })?;
let trimmed = body.trim(); let trimmed = body.trim();
log::debug!( log::debug!("Dynu response (status {}): '{}'", status_code, trimmed);
"Dynu response (status {}): '{}'",
status_code,
trimmed
);
if !status_code.is_success() { if !status_code.is_success() {
return Err(UpdateError::NetworkError { return Err(UpdateError::NetworkError {
+4 -1
View File
@@ -82,7 +82,10 @@ impl IpMonitorService {
); );
if state.last_ip == Some(discovery.ip) { 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 // Persist the updated provider index so rotation continues
state.last_provider_index = Some(discovery.provider_index); state.last_provider_index = Some(discovery.provider_index);
self.state_repo.save(&state)?; self.state_repo.save(&state)?;
+4 -2
View File
@@ -1,6 +1,8 @@
use std::net::Ipv4Addr; use ddns_monitor::domain::models::{
use ddns_monitor::domain::models::{HistoryEntry, IpDiscoveryResult, MonitorState, SubscriberResult}; HistoryEntry, IpDiscoveryResult, MonitorState, SubscriberResult,
};
use ddns_monitor::domain::validation::{is_valid_public_ipv4, next_provider_index}; use ddns_monitor::domain::validation::{is_valid_public_ipv4, next_provider_index};
use std::net::Ipv4Addr;
#[test] #[test]
fn test_is_valid_public_ipv4() { fn test_is_valid_public_ipv4() {
+2 -6
View File
@@ -90,12 +90,8 @@ fn test_dynu_updater_server_error() {
.create(); .create();
let endpoint = format!("{}/nic/update", server.url()); let endpoint = format!("{}/nic/update", server.url());
let updater = DynuUpdater::with_endpoint( let updater =
"test.example.com", DynuUpdater::with_endpoint("test.example.com", "pass", endpoint, Duration::from_secs(2));
"pass",
endpoint,
Duration::from_secs(2),
);
let res = updater.update(Ipv4Addr::new(198, 51, 100, 5)); let res = updater.update(Ipv4Addr::new(198, 51, 100, 5));
assert!(res.is_err()); assert!(res.is_err());
+4 -4
View File
@@ -1,6 +1,4 @@
use ddns_monitor::domain::errors::{ use ddns_monitor::domain::errors::{HistoryError, ResolveError, StateError, UpdateError};
HistoryError, ResolveError, StateError, UpdateError,
};
use ddns_monitor::domain::models::{HistoryEntry, IpDiscoveryResult, MonitorState}; use ddns_monitor::domain::models::{HistoryEntry, IpDiscoveryResult, MonitorState};
use ddns_monitor::domain::traits::{DdnsUpdater, HistoryRepository, IpResolver, StateRepository}; use ddns_monitor::domain::traits::{DdnsUpdater, HistoryRepository, IpResolver, StateRepository};
use ddns_monitor::service::{IpMonitorService, RunOutcome}; 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)], 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 { match outcome {
RunOutcome::AllFailed { ip, subscribers } => { RunOutcome::AllFailed { ip, subscribers } => {
assert_eq!(ip, new_ip); assert_eq!(ip, new_ip);