diff --git a/src/trx-client/trx-frontend/src/lib.rs b/src/trx-client/trx-frontend/src/lib.rs index 624befb..b615155 100644 --- a/src/trx-client/trx-frontend/src/lib.rs +++ b/src/trx-client/trx-frontend/src/lib.rs @@ -337,7 +337,6 @@ pub struct OwnerInfo { pub ais_vessel_url_base: Option, } - /// Virtual channel audio management. pub struct VChanContext { /// Per-virtual-channel Opus audio senders. diff --git a/src/trx-client/trx-frontend/trx-frontend-http/src/api.rs b/src/trx-client/trx-frontend/trx-frontend-http/src/api.rs index 9ecead8..aea5c22 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/src/api.rs +++ b/src/trx-client/trx-frontend/trx-frontend-http/src/api.rs @@ -348,7 +348,7 @@ pub async fn events( let active_rig_id = query.remote.clone().filter(|s| !s.is_empty()).or_else(|| { context .routing - .active_rig_id + .active_rig_id .lock() .ok() .and_then(|g| g.clone()) @@ -425,7 +425,7 @@ pub async fn events( let rig_id_opt = session_rig_mgr.get_rig(session_id).or_else(|| { context .routing - .active_rig_id + .active_rig_id .lock() .ok() .and_then(|g| g.clone()) @@ -448,9 +448,9 @@ pub async fn events( rig_id_opt.as_deref(), ), }; - serde_json::to_string(&combined).ok().map(|json| { - Ok::(Bytes::from(format!("data: {json}\n\n"))) - }) + serde_json::to_string(&combined) + .ok() + .map(|json| Ok::(Bytes::from(format!("data: {json}\n\n")))) }) } }); @@ -1357,7 +1357,12 @@ struct SatPassesResponse { /// are not yet available. #[get("/sat_passes")] pub async fn sat_passes(context: web::Data>) -> impl Responder { - let cached = context.routing.sat_passes.read().ok().and_then(|g| g.clone()); + let cached = context + .routing + .sat_passes + .read() + .ok() + .and_then(|g| g.clone()); match cached { Some(result) => { let error = match result.tle_source { @@ -1612,7 +1617,10 @@ fn static_asset_response( if val == etag || val == "*" { return HttpResponse::NotModified() .insert_header((header::ETAG, etag.to_owned())) - .insert_header((header::CACHE_CONTROL, "public, max-age=86400, must-revalidate")) + .insert_header(( + header::CACHE_CONTROL, + "public, max-age=86400, must-revalidate", + )) .finish(); } } @@ -1621,7 +1629,10 @@ fn static_asset_response( .insert_header((header::CONTENT_TYPE, content_type)) .insert_header((header::CONTENT_ENCODING, "gzip")) .insert_header((header::ETAG, etag.to_owned())) - .insert_header((header::CACHE_CONTROL, "public, max-age=86400, must-revalidate")) + .insert_header(( + header::CACHE_CONTROL, + "public, max-age=86400, must-revalidate", + )) .body(Bytes::copy_from_slice(gz_bytes)) } @@ -1652,9 +1663,21 @@ macro_rules! define_gz_cache { define_gz_cache!(gz_index_html, status::index_html(), "index.html"); define_gz_cache!(gz_style_css, status::STYLE_CSS, "style.css"); define_gz_cache!(gz_app_js, status::APP_JS, "app.js"); -define_gz_cache!(gz_decode_history_worker_js, status::DECODE_HISTORY_WORKER_JS, "decode-history-worker.js"); -define_gz_cache!(gz_webgl_renderer_js, status::WEBGL_RENDERER_JS, "webgl-renderer.js"); -define_gz_cache!(gz_leaflet_ais_tracksymbol_js, status::LEAFLET_AIS_TRACKSYMBOL_JS, "leaflet-ais-tracksymbol.js"); +define_gz_cache!( + gz_decode_history_worker_js, + status::DECODE_HISTORY_WORKER_JS, + "decode-history-worker.js" +); +define_gz_cache!( + gz_webgl_renderer_js, + status::WEBGL_RENDERER_JS, + "webgl-renderer.js" +); +define_gz_cache!( + gz_leaflet_ais_tracksymbol_js, + status::LEAFLET_AIS_TRACKSYMBOL_JS, + "leaflet-ais-tracksymbol.js" +); define_gz_cache!(gz_ais_js, status::AIS_JS, "ais.js"); define_gz_cache!(gz_vdes_js, status::VDES_JS, "vdes.js"); define_gz_cache!(gz_aprs_js, status::APRS_JS, "aprs.js"); @@ -1667,8 +1690,16 @@ define_gz_cache!(gz_cw_js, status::CW_JS, "cw.js"); define_gz_cache!(gz_sat_js, status::SAT_JS, "sat.js"); define_gz_cache!(gz_bookmarks_js, status::BOOKMARKS_JS, "bookmarks.js"); define_gz_cache!(gz_scheduler_js, status::SCHEDULER_JS, "scheduler.js"); -define_gz_cache!(gz_sat_scheduler_js, status::SAT_SCHEDULER_JS, "sat-scheduler.js"); -define_gz_cache!(gz_background_decode_js, status::BACKGROUND_DECODE_JS, "background-decode.js"); +define_gz_cache!( + gz_sat_scheduler_js, + status::SAT_SCHEDULER_JS, + "sat-scheduler.js" +); +define_gz_cache!( + gz_background_decode_js, + status::BACKGROUND_DECODE_JS, + "background-decode.js" +); define_gz_cache!(gz_vchan_js, status::VCHAN_JS, "vchan.js"); /// A bookmark with its owning scope tag for the list response. @@ -2308,115 +2339,210 @@ async fn style_css(req: HttpRequest) -> impl Responder { #[get("/app.js")] async fn app_js(req: HttpRequest) -> impl Responder { let c = gz_app_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/decode-history-worker.js")] async fn decode_history_worker_js(req: HttpRequest) -> impl Responder { let c = gz_decode_history_worker_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/webgl-renderer.js")] async fn webgl_renderer_js(req: HttpRequest) -> impl Responder { let c = gz_webgl_renderer_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/leaflet-ais-tracksymbol.js")] async fn leaflet_ais_tracksymbol_js(req: HttpRequest) -> impl Responder { let c = gz_leaflet_ais_tracksymbol_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/aprs.js")] async fn aprs_js(req: HttpRequest) -> impl Responder { let c = gz_aprs_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/hf-aprs.js")] async fn hf_aprs_js(req: HttpRequest) -> impl Responder { let c = gz_hf_aprs_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/ais.js")] async fn ais_js(req: HttpRequest) -> impl Responder { let c = gz_ais_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/vdes.js")] async fn vdes_js(req: HttpRequest) -> impl Responder { let c = gz_vdes_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/ft8.js")] async fn ft8_js(req: HttpRequest) -> impl Responder { let c = gz_ft8_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/ft4.js")] async fn ft4_js(req: HttpRequest) -> impl Responder { let c = gz_ft4_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/ft2.js")] async fn ft2_js(req: HttpRequest) -> impl Responder { let c = gz_ft2_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/wspr.js")] async fn wspr_js(req: HttpRequest) -> impl Responder { let c = gz_wspr_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/cw.js")] async fn cw_js(req: HttpRequest) -> impl Responder { let c = gz_cw_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/sat.js")] async fn sat_js(req: HttpRequest) -> impl Responder { let c = gz_sat_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/bookmarks.js")] async fn bookmarks_js(req: HttpRequest) -> impl Responder { let c = gz_bookmarks_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/scheduler.js")] async fn scheduler_js(req: HttpRequest) -> impl Responder { let c = gz_scheduler_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/sat-scheduler.js")] async fn sat_scheduler_js(req: HttpRequest) -> impl Responder { let c = gz_sat_scheduler_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/background-decode.js")] async fn background_decode_js(req: HttpRequest) -> impl Responder { let c = gz_background_decode_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } #[get("/vchan.js")] async fn vchan_js(req: HttpRequest) -> impl Responder { let c = gz_vchan_js(); - static_asset_response(&req, "application/javascript; charset=utf-8", &c.gz, &c.etag) + static_asset_response( + &req, + "application/javascript; charset=utf-8", + &c.gz, + &c.etag, + ) } /// Generic query extractor for endpoints that only need the optional remote. diff --git a/src/trx-client/trx-frontend/trx-frontend-http/src/audio.rs b/src/trx-client/trx-frontend/trx-frontend-http/src/audio.rs index 19ccb76..6e438a2 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/src/audio.rs +++ b/src/trx-client/trx-frontend/trx-frontend-http/src/audio.rs @@ -126,7 +126,8 @@ fn record_ais(context: &FrontendRuntimeContext, mut msg: AisMessage) { } let rig_id = msg.rig_id.clone().or_else(|| active_rig_id(context)); let mut history = context - .decode_history.ais + .decode_history + .ais .lock() .expect("ais history mutex poisoned"); history.push_back((Instant::now(), rig_id, msg)); @@ -139,7 +140,8 @@ fn record_vdes(context: &FrontendRuntimeContext, mut msg: VdesMessage) { } let rig_id = msg.rig_id.clone().or_else(|| active_rig_id(context)); let mut history = context - .decode_history.vdes + .decode_history + .vdes .lock() .expect("vdes history mutex poisoned"); history.push_back((Instant::now(), rig_id, msg)); @@ -217,7 +219,8 @@ fn record_aprs(context: &FrontendRuntimeContext, mut pkt: AprsPacket) { } let rig_id = pkt.rig_id.clone().or_else(|| active_rig_id(context)); let mut history = context - .decode_history.aprs + .decode_history + .aprs .lock() .expect("aprs history mutex poisoned"); history.push_back((Instant::now(), rig_id, pkt)); @@ -230,7 +233,8 @@ fn record_hf_aprs(context: &FrontendRuntimeContext, mut pkt: AprsPacket) { } let rig_id = pkt.rig_id.clone().or_else(|| active_rig_id(context)); let mut history = context - .decode_history.hf_aprs + .decode_history + .hf_aprs .lock() .expect("hf_aprs history mutex poisoned"); history.push_back((Instant::now(), rig_id, pkt)); @@ -240,7 +244,8 @@ fn record_hf_aprs(context: &FrontendRuntimeContext, mut pkt: AprsPacket) { fn record_cw(context: &FrontendRuntimeContext, event: CwEvent) { let rig_id = event.rig_id.clone().or_else(|| active_rig_id(context)); let mut history = context - .decode_history.cw + .decode_history + .cw .lock() .expect("cw history mutex poisoned"); history.push_back((Instant::now(), rig_id, event)); @@ -250,7 +255,8 @@ fn record_cw(context: &FrontendRuntimeContext, event: CwEvent) { fn record_ft8(context: &FrontendRuntimeContext, msg: Ft8Message) { let rig_id = msg.rig_id.clone().or_else(|| active_rig_id(context)); let mut history = context - .decode_history.ft8 + .decode_history + .ft8 .lock() .expect("ft8 history mutex poisoned"); history.push_back((Instant::now(), rig_id, msg)); @@ -260,7 +266,8 @@ fn record_ft8(context: &FrontendRuntimeContext, msg: Ft8Message) { fn record_ft4(context: &FrontendRuntimeContext, msg: Ft8Message) { let rig_id = msg.rig_id.clone().or_else(|| active_rig_id(context)); let mut history = context - .decode_history.ft4 + .decode_history + .ft4 .lock() .expect("ft4 history mutex poisoned"); history.push_back((Instant::now(), rig_id, msg)); @@ -270,7 +277,8 @@ fn record_ft4(context: &FrontendRuntimeContext, msg: Ft8Message) { fn record_ft2(context: &FrontendRuntimeContext, msg: Ft8Message) { let rig_id = msg.rig_id.clone().or_else(|| active_rig_id(context)); let mut history = context - .decode_history.ft2 + .decode_history + .ft2 .lock() .expect("ft2 history mutex poisoned"); history.push_back((Instant::now(), rig_id, msg)); @@ -280,7 +288,8 @@ fn record_ft2(context: &FrontendRuntimeContext, msg: Ft8Message) { fn record_wspr(context: &FrontendRuntimeContext, msg: WsprMessage) { let rig_id = msg.rig_id.clone().or_else(|| active_rig_id(context)); let mut history = context - .decode_history.wspr + .decode_history + .wspr .lock() .expect("wspr history mutex poisoned"); history.push_back((Instant::now(), rig_id, msg)); @@ -301,7 +310,8 @@ pub fn snapshot_aprs_history( rig_filter: Option<&str>, ) -> Vec { let mut history = context - .decode_history.aprs + .decode_history + .aprs .lock() .expect("aprs history mutex poisoned"); prune_aprs_history(context, &mut history); @@ -317,7 +327,8 @@ pub fn snapshot_hf_aprs_history( rig_filter: Option<&str>, ) -> Vec { let mut history = context - .decode_history.hf_aprs + .decode_history + .hf_aprs .lock() .expect("hf_aprs history mutex poisoned"); prune_hf_aprs_history(context, &mut history); @@ -340,7 +351,8 @@ pub fn snapshot_ais_history( rig_filter: Option<&str>, ) -> Vec { let mut history = context - .decode_history.ais + .decode_history + .ais .lock() .expect("ais history mutex poisoned"); prune_ais_history(context, &mut history); @@ -362,7 +374,8 @@ pub fn snapshot_vdes_history( rig_filter: Option<&str>, ) -> Vec { let mut history = context - .decode_history.vdes + .decode_history + .vdes .lock() .expect("vdes history mutex poisoned"); prune_vdes_history(context, &mut history); @@ -378,7 +391,8 @@ pub fn snapshot_cw_history( rig_filter: Option<&str>, ) -> Vec { let mut history = context - .decode_history.cw + .decode_history + .cw .lock() .expect("cw history mutex poisoned"); prune_cw_history(context, &mut history); @@ -394,7 +408,8 @@ pub fn snapshot_ft8_history( rig_filter: Option<&str>, ) -> Vec { let mut history = context - .decode_history.ft8 + .decode_history + .ft8 .lock() .expect("ft8 history mutex poisoned"); prune_ft8_history(context, &mut history); @@ -410,7 +425,8 @@ pub fn snapshot_ft4_history( rig_filter: Option<&str>, ) -> Vec { let mut history = context - .decode_history.ft4 + .decode_history + .ft4 .lock() .expect("ft4 history mutex poisoned"); prune_ft4_history(context, &mut history); @@ -426,7 +442,8 @@ pub fn snapshot_ft2_history( rig_filter: Option<&str>, ) -> Vec { let mut history = context - .decode_history.ft2 + .decode_history + .ft2 .lock() .expect("ft2 history mutex poisoned"); prune_ft2_history(context, &mut history); @@ -442,7 +459,8 @@ pub fn snapshot_wspr_history( rig_filter: Option<&str>, ) -> Vec { let mut history = context - .decode_history.wspr + .decode_history + .wspr .lock() .expect("wspr history mutex poisoned"); prune_wspr_history(context, &mut history); @@ -455,7 +473,8 @@ pub fn snapshot_wspr_history( pub fn clear_aprs_history(context: &FrontendRuntimeContext) { let mut history = context - .decode_history.aprs + .decode_history + .aprs .lock() .expect("aprs history mutex poisoned"); history.clear(); @@ -463,7 +482,8 @@ pub fn clear_aprs_history(context: &FrontendRuntimeContext) { pub fn clear_hf_aprs_history(context: &FrontendRuntimeContext) { let mut history = context - .decode_history.hf_aprs + .decode_history + .hf_aprs .lock() .expect("hf_aprs history mutex poisoned"); history.clear(); @@ -471,7 +491,8 @@ pub fn clear_hf_aprs_history(context: &FrontendRuntimeContext) { pub fn clear_ais_history(context: &FrontendRuntimeContext) { let mut history = context - .decode_history.ais + .decode_history + .ais .lock() .expect("ais history mutex poisoned"); history.clear(); @@ -479,7 +500,8 @@ pub fn clear_ais_history(context: &FrontendRuntimeContext) { pub fn clear_vdes_history(context: &FrontendRuntimeContext) { let mut history = context - .decode_history.vdes + .decode_history + .vdes .lock() .expect("vdes history mutex poisoned"); history.clear(); @@ -487,7 +509,8 @@ pub fn clear_vdes_history(context: &FrontendRuntimeContext) { pub fn clear_cw_history(context: &FrontendRuntimeContext) { let mut history = context - .decode_history.cw + .decode_history + .cw .lock() .expect("cw history mutex poisoned"); history.clear(); @@ -495,7 +518,8 @@ pub fn clear_cw_history(context: &FrontendRuntimeContext) { pub fn clear_ft8_history(context: &FrontendRuntimeContext) { let mut history = context - .decode_history.ft8 + .decode_history + .ft8 .lock() .expect("ft8 history mutex poisoned"); history.clear(); @@ -503,7 +527,8 @@ pub fn clear_ft8_history(context: &FrontendRuntimeContext) { pub fn clear_ft4_history(context: &FrontendRuntimeContext) { let mut history = context - .decode_history.ft4 + .decode_history + .ft4 .lock() .expect("ft4 history mutex poisoned"); history.clear(); @@ -511,7 +536,8 @@ pub fn clear_ft4_history(context: &FrontendRuntimeContext) { pub fn clear_ft2_history(context: &FrontendRuntimeContext) { let mut history = context - .decode_history.ft2 + .decode_history + .ft2 .lock() .expect("ft2 history mutex poisoned"); history.clear(); @@ -519,7 +545,8 @@ pub fn clear_ft2_history(context: &FrontendRuntimeContext) { pub fn clear_wspr_history(context: &FrontendRuntimeContext) { let mut history = context - .decode_history.wspr + .decode_history + .wspr .lock() .expect("wspr history mutex poisoned"); history.clear(); diff --git a/src/trx-client/trx-frontend/trx-frontend-http/src/background_decode.rs b/src/trx-client/trx-frontend/trx-frontend-http/src/background_decode.rs index 9801dbf..81501b3 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/src/background_decode.rs +++ b/src/trx-client/trx-frontend/trx-frontend-http/src/background_decode.rs @@ -6,8 +6,8 @@ use std::collections::HashMap; use std::path::{Path, PathBuf}; use std::sync::atomic::Ordering; use std::sync::Arc; -use tokio::sync::RwLock; use std::time::Duration; +use tokio::sync::RwLock; use actix_web::{delete, get, put, web, HttpResponse, Responder}; use pickledb::{PickleDb, PickleDbDumpPolicy, SerializationMethod}; @@ -183,7 +183,10 @@ impl BackgroundDecodeManager { }) } - pub async fn put_config(&self, mut config: BackgroundDecodeConfig) -> Option { + pub async fn put_config( + &self, + mut config: BackgroundDecodeConfig, + ) -> Option { config.bookmark_ids = dedup_ids(&config.bookmark_ids); if self.store.upsert(&config).await { self.trigger(); diff --git a/src/trx-core/src/geo.rs b/src/trx-core/src/geo.rs index d11c354..5bc212c 100644 --- a/src/trx-core/src/geo.rs +++ b/src/trx-core/src/geo.rs @@ -468,11 +468,14 @@ fn find_passes_for_sat( start_ms: i64, window_ms: i64, ) -> Vec { - let elements = - match Elements::from_tle(Some(entry.name.clone()), entry.line1.as_bytes(), entry.line2.as_bytes()) { - Ok(e) => e, - Err(_) => return vec![], - }; + let elements = match Elements::from_tle( + Some(entry.name.clone()), + entry.line1.as_bytes(), + entry.line2.as_bytes(), + ) { + Ok(e) => e, + Err(_) => return vec![], + }; let constants = match Constants::from_elements(&elements) { Ok(c) => c, Err(_) => return vec![], diff --git a/src/trx-core/src/rig/controller/policies.rs b/src/trx-core/src/rig/controller/policies.rs index e89d6e5..4c446ed 100644 --- a/src/trx-core/src/rig/controller/policies.rs +++ b/src/trx-core/src/rig/controller/policies.rs @@ -15,15 +15,12 @@ use crate::rig::response::RigError; fn apply_jitter(delay: Duration) -> Duration { // Simple deterministic-ish jitter using the current instant's low bits. // We avoid pulling in `rand` for this single use. - let nanos = std::time::Instant::now() - .elapsed() - .as_nanos() - .wrapping_add( - std::time::SystemTime::now() - .duration_since(std::time::UNIX_EPOCH) - .unwrap_or_default() - .as_nanos(), - ); + let nanos = std::time::Instant::now().elapsed().as_nanos().wrapping_add( + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap_or_default() + .as_nanos(), + ); // Map to range [0.75, 1.25] let frac = (nanos % 1000) as f64 / 1000.0; // 0.0 .. 1.0 let factor = 0.75 + frac * 0.5; // 0.75 .. 1.25 diff --git a/src/trx-server/src/audio.rs b/src/trx-server/src/audio.rs index c6bfcf0..6746780 100644 --- a/src/trx-server/src/audio.rs +++ b/src/trx-server/src/audio.rs @@ -383,7 +383,9 @@ impl DecoderHistories { let before = h.len(); Self::prune_aprs(&mut h); self.adjust_total_count(before, h.len()); - h.iter().map(|(_, pkt): &(Instant, AprsPacket)| pkt.clone()).collect() + h.iter() + .map(|(_, pkt): &(Instant, AprsPacket)| pkt.clone()) + .collect() } pub fn clear_aprs_history(&self) { @@ -426,7 +428,9 @@ impl DecoderHistories { let before = h.len(); Self::prune_hf_aprs(&mut h); self.adjust_total_count(before, h.len()); - h.iter().map(|(_, pkt): &(Instant, AprsPacket)| pkt.clone()).collect() + h.iter() + .map(|(_, pkt): &(Instant, AprsPacket)| pkt.clone()) + .collect() } pub fn clear_hf_aprs_history(&self) { @@ -463,7 +467,9 @@ impl DecoderHistories { let before = h.len(); Self::prune_cw(&mut h); self.adjust_total_count(before, h.len()); - h.iter().map(|(_, evt): &(Instant, CwEvent)| evt.clone()).collect() + h.iter() + .map(|(_, evt): &(Instant, CwEvent)| evt.clone()) + .collect() } pub fn clear_cw_history(&self) { @@ -500,7 +506,9 @@ impl DecoderHistories { let before = h.len(); Self::prune_ft8(&mut h); self.adjust_total_count(before, h.len()); - h.iter().map(|(_, msg): &(Instant, Ft8Message)| msg.clone()).collect() + h.iter() + .map(|(_, msg): &(Instant, Ft8Message)| msg.clone()) + .collect() } pub fn clear_ft8_history(&self) { @@ -537,7 +545,9 @@ impl DecoderHistories { let before = h.len(); Self::prune_ft4(&mut h); self.adjust_total_count(before, h.len()); - h.iter().map(|(_, msg): &(Instant, Ft8Message)| msg.clone()).collect() + h.iter() + .map(|(_, msg): &(Instant, Ft8Message)| msg.clone()) + .collect() } pub fn clear_ft4_history(&self) { @@ -574,7 +584,9 @@ impl DecoderHistories { let before = h.len(); Self::prune_ft2(&mut h); self.adjust_total_count(before, h.len()); - h.iter().map(|(_, msg): &(Instant, Ft8Message)| msg.clone()).collect() + h.iter() + .map(|(_, msg): &(Instant, Ft8Message)| msg.clone()) + .collect() } pub fn clear_ft2_history(&self) { @@ -611,7 +623,9 @@ impl DecoderHistories { let before = h.len(); Self::prune_wspr(&mut h); self.adjust_total_count(before, h.len()); - h.iter().map(|(_, msg): &(Instant, WsprMessage)| msg.clone()).collect() + h.iter() + .map(|(_, msg): &(Instant, WsprMessage)| msg.clone()) + .collect() } pub fn clear_wspr_history(&self) { @@ -651,7 +665,9 @@ impl DecoderHistories { let before = h.len(); Self::prune_lrpt(&mut h); self.adjust_total_count(before, h.len()); - h.iter().map(|(_, img): &(Instant, LrptImage)| img.clone()).collect() + h.iter() + .map(|(_, img): &(Instant, LrptImage)| img.clone()) + .collect() } pub fn clear_lrpt_history(&self) { @@ -735,15 +751,13 @@ fn find_device( host.output_devices() }; match devices_result { - Ok(mut devs) => { - match devs.find(|d| d.name().map(|n| n == *name).unwrap_or(false)) { - Some(d) => Some(d), - None => { - warn!("Audio {}: device '{}' not found, retrying", direction, name); - None - } + Ok(mut devs) => match devs.find(|d| d.name().map(|n| n == *name).unwrap_or(false)) { + Some(d) => Some(d), + None => { + warn!("Audio {}: device '{}' not found, retrying", direction, name); + None } - } + }, Err(e) => { warn!( "Audio {}: failed to enumerate devices, retrying: {}", diff --git a/src/trx-server/src/listener.rs b/src/trx-server/src/listener.rs index 60f7dc8..213db9a 100644 --- a/src/trx-server/src/listener.rs +++ b/src/trx-server/src/listener.rs @@ -382,18 +382,15 @@ async fn handle_client( // SGP4 propagation when multiple clients request passes concurrently. if matches!(envelope.cmd, ClientCommand::GetSatPasses) { // Check cache first. - let cached = sat_pass_cache - .lock() - .ok() - .and_then(|guard| { - guard.as_ref().and_then(|c| { - if c.computed_at.elapsed() < SAT_PASS_CACHE_TTL { - Some(c.result.clone()) - } else { - None - } - }) - }); + let cached = sat_pass_cache.lock().ok().and_then(|guard| { + guard.as_ref().and_then(|c| { + if c.computed_at.elapsed() < SAT_PASS_CACHE_TTL { + Some(c.result.clone()) + } else { + None + } + }) + }); let result = if let Some(cached_result) = cached { cached_result @@ -693,7 +690,15 @@ mod tests { let mut auth = HashSet::new(); auth.insert("secret".to_string()); - let handle = tokio::spawn(run_listener(addr, rigs, default_id, auth, None, ListenerTimeouts::default(), shutdown_rx)); + let handle = tokio::spawn(run_listener( + addr, + rigs, + default_id, + auth, + None, + ListenerTimeouts::default(), + shutdown_rx, + )); let stream = TcpStream::connect(addr).await.expect("connect"); let (reader, mut writer) = stream.into_split(); diff --git a/src/trx-server/trx-backend/trx-backend-ft817/src/lib.rs b/src/trx-server/trx-backend/trx-backend-ft817/src/lib.rs index 3be6476..4307e83 100644 --- a/src/trx-server/trx-backend/trx-backend-ft817/src/lib.rs +++ b/src/trx-server/trx-backend/trx-backend-ft817/src/lib.rs @@ -486,7 +486,6 @@ impl Ft817 { } } } - } impl Rig for Ft817 {