fix(trx-server): remove unused RigSdr import in rig_task.rs

Also run cargo fmt to fix formatting issues across trx-server,
trx-frontend-http, and trx-configurator.

https://claude.ai/code/session_01RsHUyVz2wjQjsEsxJo5owt
Signed-off-by: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2026-03-26 12:59:16 +00:00
committed by Stan Grams
parent c8f33b8939
commit a63f27971d
10 changed files with 413 additions and 130 deletions
@@ -527,15 +527,17 @@ fn sync_scheduler_vchannels(
.last_bookmark_ids
.iter()
.filter_map(|bookmark_id| {
bookmark_store_map.get_for_rig(rig_id, bookmark_id).map(|bookmark| {
(
bookmark_id.clone(),
bookmark.freq_hz,
bookmark.mode.clone(),
bookmark.bandwidth_hz.unwrap_or(0) as u32,
bookmark_decoder_kinds(&bookmark),
)
})
bookmark_store_map
.get_for_rig(rig_id, bookmark_id)
.map(|bookmark| {
(
bookmark_id.clone(),
bookmark.freq_hz,
bookmark.mode.clone(),
bookmark.bandwidth_hz.unwrap_or(0) as u32,
bookmark_decoder_kinds(&bookmark),
)
})
})
.collect::<Vec<_>>()
})
@@ -573,7 +575,10 @@ impl DecodeHistoryPayload {
/// Build the grouped decode history payload from all per-decoder ring-buffers.
/// When `rig_filter` is `Some`, only entries recorded for that rig are included.
fn collect_decode_history(context: &FrontendRuntimeContext, rig_filter: Option<&str>) -> DecodeHistoryPayload {
fn collect_decode_history(
context: &FrontendRuntimeContext,
rig_filter: Option<&str>,
) -> DecodeHistoryPayload {
DecodeHistoryPayload {
ais: crate::server::audio::snapshot_ais_history(context, rig_filter),
vdes: crate::server::audio::snapshot_vdes_history(context, rig_filter),
@@ -1497,7 +1502,10 @@ pub async fn list_bookmarks(
status::index_html(),
));
}
let scope = query.scope.as_deref().filter(|s| !s.is_empty() && *s != "general");
let scope = query
.scope
.as_deref()
.filter(|s| !s.is_empty() && *s != "general");
let mut list: Vec<BookmarkWithScope> = match scope {
Some(remote) => {
// Rig selected: merge general + rig-specific (rig wins on duplicate IDs).
@@ -1507,20 +1515,36 @@ pub async fn list_bookmarks(
.into_iter()
.map(|bm| {
let id = bm.id.clone();
(id, BookmarkWithScope { bm, scope: "general".into() })
(
id,
BookmarkWithScope {
bm,
scope: "general".into(),
},
)
})
.collect();
for bm in store_map.store_for(remote).list() {
let id = bm.id.clone();
map.insert(id, BookmarkWithScope { bm, scope: remote.to_owned() });
map.insert(
id,
BookmarkWithScope {
bm,
scope: remote.to_owned(),
},
);
}
map.into_values().collect()
}
None => {
store_map.general().list().into_iter()
.map(|bm| BookmarkWithScope { bm, scope: "general".into() })
.collect()
}
None => store_map
.general()
.list()
.into_iter()
.map(|bm| BookmarkWithScope {
bm,
scope: "general".into(),
})
.collect(),
};
if let Some(ref cat) = query.category {
if !cat.is_empty() {
@@ -141,7 +141,10 @@ fn record_vdes(context: &FrontendRuntimeContext, mut msg: VdesMessage) {
prune_vdes_history(context, &mut history);
}
fn prune_cw_history(context: &FrontendRuntimeContext, history: &mut VecDeque<(Instant, Option<String>, CwEvent)>) {
fn prune_cw_history(
context: &FrontendRuntimeContext,
history: &mut VecDeque<(Instant, Option<String>, CwEvent)>,
) {
let cutoff = decode_history_cutoff(context);
while let Some((ts, _, _)) = history.front() {
if *ts >= cutoff {
@@ -281,25 +284,33 @@ fn matches_rig_filter(entry_rig: Option<&str>, filter: Option<&str>) -> bool {
}
}
pub fn snapshot_aprs_history(context: &FrontendRuntimeContext, rig_filter: Option<&str>) -> Vec<AprsPacket> {
pub fn snapshot_aprs_history(
context: &FrontendRuntimeContext,
rig_filter: Option<&str>,
) -> Vec<AprsPacket> {
let mut history = context
.aprs_history
.lock()
.expect("aprs history mutex poisoned");
prune_aprs_history(context, &mut history);
history.iter()
history
.iter()
.filter(|(_, rid, _)| matches_rig_filter(rid.as_deref(), rig_filter))
.map(|(_, _, pkt)| pkt.clone())
.collect()
}
pub fn snapshot_hf_aprs_history(context: &FrontendRuntimeContext, rig_filter: Option<&str>) -> Vec<AprsPacket> {
pub fn snapshot_hf_aprs_history(
context: &FrontendRuntimeContext,
rig_filter: Option<&str>,
) -> Vec<AprsPacket> {
let mut history = context
.hf_aprs_history
.lock()
.expect("hf_aprs history mutex poisoned");
prune_hf_aprs_history(context, &mut history);
history.iter()
history
.iter()
.filter(|(_, rid, _)| matches_rig_filter(rid.as_deref(), rig_filter))
.map(|(_, _, pkt)| pkt.clone())
.collect()
@@ -312,7 +323,10 @@ pub fn snapshot_hf_aprs_history(context: &FrontendRuntimeContext, rig_filter: Op
/// what the map shows (current position/state) and keeps the response compact.
/// The returned vec is sorted ascending by `ts_ms` so the client can replay
/// in chronological order.
pub fn snapshot_ais_history(context: &FrontendRuntimeContext, rig_filter: Option<&str>) -> Vec<AisMessage> {
pub fn snapshot_ais_history(
context: &FrontendRuntimeContext,
rig_filter: Option<&str>,
) -> Vec<AisMessage> {
let mut history = context
.ais_history
.lock()
@@ -331,73 +345,97 @@ pub fn snapshot_ais_history(context: &FrontendRuntimeContext, rig_filter: Option
out
}
pub fn snapshot_vdes_history(context: &FrontendRuntimeContext, rig_filter: Option<&str>) -> Vec<VdesMessage> {
pub fn snapshot_vdes_history(
context: &FrontendRuntimeContext,
rig_filter: Option<&str>,
) -> Vec<VdesMessage> {
let mut history = context
.vdes_history
.lock()
.expect("vdes history mutex poisoned");
prune_vdes_history(context, &mut history);
history.iter()
history
.iter()
.filter(|(_, rid, _)| matches_rig_filter(rid.as_deref(), rig_filter))
.map(|(_, _, msg)| msg.clone())
.collect()
}
pub fn snapshot_cw_history(context: &FrontendRuntimeContext, rig_filter: Option<&str>) -> Vec<CwEvent> {
pub fn snapshot_cw_history(
context: &FrontendRuntimeContext,
rig_filter: Option<&str>,
) -> Vec<CwEvent> {
let mut history = context
.cw_history
.lock()
.expect("cw history mutex poisoned");
prune_cw_history(context, &mut history);
history.iter()
history
.iter()
.filter(|(_, rid, _)| matches_rig_filter(rid.as_deref(), rig_filter))
.map(|(_, _, evt)| evt.clone())
.collect()
}
pub fn snapshot_ft8_history(context: &FrontendRuntimeContext, rig_filter: Option<&str>) -> Vec<Ft8Message> {
pub fn snapshot_ft8_history(
context: &FrontendRuntimeContext,
rig_filter: Option<&str>,
) -> Vec<Ft8Message> {
let mut history = context
.ft8_history
.lock()
.expect("ft8 history mutex poisoned");
prune_ft8_history(context, &mut history);
history.iter()
history
.iter()
.filter(|(_, rid, _)| matches_rig_filter(rid.as_deref(), rig_filter))
.map(|(_, _, msg)| msg.clone())
.collect()
}
pub fn snapshot_ft4_history(context: &FrontendRuntimeContext, rig_filter: Option<&str>) -> Vec<Ft8Message> {
pub fn snapshot_ft4_history(
context: &FrontendRuntimeContext,
rig_filter: Option<&str>,
) -> Vec<Ft8Message> {
let mut history = context
.ft4_history
.lock()
.expect("ft4 history mutex poisoned");
prune_ft4_history(context, &mut history);
history.iter()
history
.iter()
.filter(|(_, rid, _)| matches_rig_filter(rid.as_deref(), rig_filter))
.map(|(_, _, msg)| msg.clone())
.collect()
}
pub fn snapshot_ft2_history(context: &FrontendRuntimeContext, rig_filter: Option<&str>) -> Vec<Ft8Message> {
pub fn snapshot_ft2_history(
context: &FrontendRuntimeContext,
rig_filter: Option<&str>,
) -> Vec<Ft8Message> {
let mut history = context
.ft2_history
.lock()
.expect("ft2 history mutex poisoned");
prune_ft2_history(context, &mut history);
history.iter()
history
.iter()
.filter(|(_, rid, _)| matches_rig_filter(rid.as_deref(), rig_filter))
.map(|(_, _, msg)| msg.clone())
.collect()
}
pub fn snapshot_wspr_history(context: &FrontendRuntimeContext, rig_filter: Option<&str>) -> Vec<WsprMessage> {
pub fn snapshot_wspr_history(
context: &FrontendRuntimeContext,
rig_filter: Option<&str>,
) -> Vec<WsprMessage> {
let mut history = context
.wspr_history
.lock()
.expect("wspr history mutex poisoned");
prune_wspr_history(context, &mut history);
history.iter()
history
.iter()
.filter(|(_, rid, _)| matches_rig_filter(rid.as_deref(), rig_filter))
.map(|(_, _, msg)| msg.clone())
.collect()
@@ -202,10 +202,7 @@ impl SchedulerStoreMap {
/// List configs from all known per-rig stores.
pub fn list_all(&self) -> Vec<SchedulerConfig> {
let stores = self.stores.lock().unwrap_or_else(|e| e.into_inner());
stores
.values()
.filter_map(|s| s.get_config())
.collect()
stores.values().filter_map(|s| s.get_config()).collect()
}
/// One-time migration: extract `sch:{remote}` entries from legacy
@@ -887,13 +884,16 @@ pub async fn get_scheduler(
store_map: web::Data<Arc<SchedulerStoreMap>>,
) -> impl Responder {
let remote = path.into_inner();
let config = store_map.store_for(&remote).get_config().unwrap_or(SchedulerConfig {
remote: remote.clone(),
mode: SchedulerMode::Disabled,
grayline: None,
entries: vec![],
interleave_min: None,
});
let config = store_map
.store_for(&remote)
.get_config()
.unwrap_or(SchedulerConfig {
remote: remote.clone(),
mode: SchedulerMode::Disabled,
grayline: None,
entries: vec![],
interleave_min: None,
});
HttpResponse::Ok().json(config)
}
@@ -160,7 +160,12 @@ impl ClientChannelManager {
}
}
// Fall back to global sender.
if let Some(tx) = self.audio_cmd.lock().unwrap_or_else(|e| e.into_inner()).as_ref() {
if let Some(tx) = self
.audio_cmd
.lock()
.unwrap_or_else(|e| e.into_inner())
.as_ref()
{
let _ = tx.try_send(cmd);
}
}
@@ -540,7 +545,11 @@ impl ClientChannelManager {
/// Return the channel a session is currently subscribed to.
pub fn session_channel(&self, session_id: Uuid) -> Option<(String, Uuid)> {
self.sessions.read().unwrap_or_else(|e| e.into_inner()).get(&session_id).cloned()
self.sessions
.read()
.unwrap_or_else(|e| e.into_inner())
.get(&session_id)
.cloned()
}
/// Return the selected channel's tune metadata.