[style](trx-rs): reformat codebase

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Stanislaw Grams <stanislawgrams@gmail.com>
This commit is contained in:
2026-03-17 22:36:11 +01:00
parent a823e66816
commit b533d704a1
22 changed files with 348 additions and 252 deletions
+6 -2
View File
@@ -3,9 +3,9 @@
// SPDX-License-Identifier: BSD-2-Clause
use std::collections::{HashMap, HashSet, VecDeque};
use std::sync::RwLock;
use std::net::SocketAddr;
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::sync::RwLock;
use std::sync::{Arc, Mutex};
use std::time::Instant;
@@ -95,7 +95,11 @@ pub struct SharedSpectrum {
impl SharedSpectrum {
/// Replace the stored frame, pre-serialising RDS in one pass.
pub fn set(&mut self, frame: Option<SpectrumData>, vchan_rds: Option<Vec<trx_core::rig::state::VchanRdsEntry>>) {
pub fn set(
&mut self,
frame: Option<SpectrumData>,
vchan_rds: Option<Vec<trx_core::rig::state::VchanRdsEntry>>,
) {
self.rds_json = frame
.as_ref()
.and_then(|f| f.rds.as_ref())
@@ -47,8 +47,16 @@ fn base64_encode(data: &[u8]) -> String {
let n = (b0 << 16) | (b1 << 8) | b2;
out.push(T[((n >> 18) & 63) as usize]);
out.push(T[((n >> 12) & 63) as usize]);
out.push(if chunk.len() > 1 { T[((n >> 6) & 63) as usize] } else { b'=' });
out.push(if chunk.len() > 2 { T[(n & 63) as usize] } else { b'=' });
out.push(if chunk.len() > 1 {
T[((n >> 6) & 63) as usize]
} else {
b'='
});
out.push(if chunk.len() > 2 {
T[(n & 63) as usize]
} else {
b'='
});
}
// SAFETY: output contains only ASCII base64 characters.
unsafe { String::from_utf8_unchecked(out) }
@@ -120,23 +128,53 @@ fn inject_frontend_meta(json: &str, meta: FrontendMeta) -> String {
// Build only the extra key-value pairs as a JSON fragment.
let mut extra = serde_json::Map::new();
extra.insert("clients".into(), serde_json::json!(meta.http_clients));
extra.insert("rigctl_clients".into(), serde_json::json!(meta.rigctl_clients));
if let Some(v) = meta.rigctl_addr { extra.insert("rigctl_addr".into(), serde_json::json!(v)); }
if let Some(v) = meta.active_rig_id { extra.insert("active_rig_id".into(), serde_json::json!(v)); }
extra.insert(
"rigctl_clients".into(),
serde_json::json!(meta.rigctl_clients),
);
if let Some(v) = meta.rigctl_addr {
extra.insert("rigctl_addr".into(), serde_json::json!(v));
}
if let Some(v) = meta.active_rig_id {
extra.insert("active_rig_id".into(), serde_json::json!(v));
}
extra.insert("rig_ids".into(), serde_json::json!(meta.rig_ids));
if let Some(v) = meta.owner_callsign { extra.insert("owner_callsign".into(), serde_json::json!(v)); }
if let Some(v) = meta.owner_website_url { extra.insert("owner_website_url".into(), serde_json::json!(v)); }
if let Some(v) = meta.owner_website_name { extra.insert("owner_website_name".into(), serde_json::json!(v)); }
if let Some(v) = meta.ais_vessel_url_base { extra.insert("ais_vessel_url_base".into(), serde_json::json!(v)); }
extra.insert("show_sdr_gain_control".into(), serde_json::json!(meta.show_sdr_gain_control));
extra.insert("initial_map_zoom".into(), serde_json::json!(meta.initial_map_zoom));
extra.insert("spectrum_coverage_margin_hz".into(), serde_json::json!(meta.spectrum_coverage_margin_hz));
extra.insert("spectrum_usable_span_ratio".into(), serde_json::json!(meta.spectrum_usable_span_ratio));
if let Some(v) = meta.owner_callsign {
extra.insert("owner_callsign".into(), serde_json::json!(v));
}
if let Some(v) = meta.owner_website_url {
extra.insert("owner_website_url".into(), serde_json::json!(v));
}
if let Some(v) = meta.owner_website_name {
extra.insert("owner_website_name".into(), serde_json::json!(v));
}
if let Some(v) = meta.ais_vessel_url_base {
extra.insert("ais_vessel_url_base".into(), serde_json::json!(v));
}
extra.insert(
"show_sdr_gain_control".into(),
serde_json::json!(meta.show_sdr_gain_control),
);
extra.insert(
"initial_map_zoom".into(),
serde_json::json!(meta.initial_map_zoom),
);
extra.insert(
"spectrum_coverage_margin_hz".into(),
serde_json::json!(meta.spectrum_coverage_margin_hz),
);
extra.insert(
"spectrum_usable_span_ratio".into(),
serde_json::json!(meta.spectrum_usable_span_ratio),
);
extra.insert(
"decode_history_retention_min".into(),
serde_json::json!(meta.decode_history_retention_min),
);
extra.insert("server_connected".into(), serde_json::json!(meta.server_connected));
extra.insert(
"server_connected".into(),
serde_json::json!(meta.server_connected),
);
// Serialize the extra map, strip its outer braces, and splice in.
let extra_json = match serde_json::to_string(&extra) {
@@ -328,9 +366,7 @@ pub async fn events(
let scheduler_control = scheduler_control_updates.clone();
async move {
state.snapshot().and_then(|v| {
if let Ok(Some(rig_id)) =
context.remote_active_rig_id.lock().map(|g| g.clone())
{
if let Ok(Some(rig_id)) = context.remote_active_rig_id.lock().map(|g| g.clone()) {
vchan.update_primary(
&rig_id,
v.status.freq.hz,
@@ -367,9 +403,8 @@ pub async fn events(
if let Some(colon) = msg.find(':') {
let rig_id = &msg[..colon];
let channels_json = &msg[colon + 1..];
let payload = format!(
"{{\"rig_id\":\"{rig_id}\",\"channels\":{channels_json}}}"
);
let payload =
format!("{{\"rig_id\":\"{rig_id}\",\"channels\":{channels_json}}}");
return Some((
Ok::<Bytes, Error>(Bytes::from(format!(
"event: channels\ndata: {payload}\n\n"
@@ -573,9 +608,7 @@ fn gzip_bytes(payload: &[u8]) -> std::io::Result<Vec<u8>> {
/// not block real-time messages: the client fetches this endpoint in parallel
/// with opening the SSE connection and drains it in the background.
#[get("/decode/history")]
pub async fn decode_history(
context: web::Data<Arc<FrontendRuntimeContext>>,
) -> impl Responder {
pub async fn decode_history(context: web::Data<Arc<FrontendRuntimeContext>>) -> impl Responder {
if context.decode_rx.is_none() {
return HttpResponse::NotFound().body("decode not enabled");
}
@@ -1414,9 +1447,7 @@ pub async fn delete_channel_route(
let (rig_id, channel_id) = path.into_inner();
match vchan_mgr.delete_channel(&rig_id, channel_id) {
Ok(()) => HttpResponse::Ok().finish(),
Err(crate::server::vchan::VChanClientError::NotFound) => {
HttpResponse::NotFound().finish()
}
Err(crate::server::vchan::VChanClientError::NotFound) => HttpResponse::NotFound().finish(),
Err(crate::server::vchan::VChanClientError::Permanent) => {
HttpResponse::BadRequest().body("cannot remove the primary channel")
}
@@ -1476,9 +1507,7 @@ pub async fn set_vchan_freq(
let (rig_id, channel_id) = path.into_inner();
match vchan_mgr.set_channel_freq(&rig_id, channel_id, body.freq_hz) {
Ok(()) => HttpResponse::Ok().finish(),
Err(crate::server::vchan::VChanClientError::NotFound) => {
HttpResponse::NotFound().finish()
}
Err(crate::server::vchan::VChanClientError::NotFound) => HttpResponse::NotFound().finish(),
Err(e) => HttpResponse::BadRequest().body(e.to_string()),
}
}
@@ -1497,9 +1526,7 @@ pub async fn set_vchan_bw(
let (rig_id, channel_id) = path.into_inner();
match vchan_mgr.set_channel_bandwidth(&rig_id, channel_id, body.bandwidth_hz) {
Ok(()) => HttpResponse::Ok().finish(),
Err(crate::server::vchan::VChanClientError::NotFound) => {
HttpResponse::NotFound().finish()
}
Err(crate::server::vchan::VChanClientError::NotFound) => HttpResponse::NotFound().finish(),
Err(e) => HttpResponse::BadRequest().body(e.to_string()),
}
}
@@ -1518,9 +1545,7 @@ pub async fn set_vchan_mode(
let (rig_id, channel_id) = path.into_inner();
match vchan_mgr.set_channel_mode(&rig_id, channel_id, &body.mode) {
Ok(()) => HttpResponse::Ok().finish(),
Err(crate::server::vchan::VChanClientError::NotFound) => {
HttpResponse::NotFound().finish()
}
Err(crate::server::vchan::VChanClientError::NotFound) => HttpResponse::NotFound().finish(),
Err(e) => HttpResponse::BadRequest().body(e.to_string()),
}
}
@@ -1783,14 +1808,20 @@ async fn ft8_js() -> impl Responder {
#[get("/ft4.js")]
async fn ft4_js() -> impl Responder {
HttpResponse::Ok()
.insert_header((header::CONTENT_TYPE, "application/javascript; charset=utf-8"))
.insert_header((
header::CONTENT_TYPE,
"application/javascript; charset=utf-8",
))
.body(status::FT4_JS)
}
#[get("/ft2.js")]
async fn ft2_js() -> impl Responder {
HttpResponse::Ok()
.insert_header((header::CONTENT_TYPE, "application/javascript; charset=utf-8"))
.insert_header((
header::CONTENT_TYPE,
"application/javascript; charset=utf-8",
))
.body(status::FT2_JS)
}
@@ -1951,7 +1982,14 @@ fn bookmark_decoder_state(
}
}
(want_aprs, want_hf_aprs, want_ft8, want_ft4, want_ft2, want_wspr)
(
want_aprs,
want_hf_aprs,
want_ft8,
want_ft4,
want_ft2,
want_wspr,
)
}
fn bookmark_decoder_kinds(bookmark: &crate::server::bookmarks::Bookmark) -> Vec<String> {
@@ -2018,7 +2056,8 @@ async fn apply_selected_channel(
let Some(bookmark) = bookmark_store.get(bookmark_id) else {
return Ok(());
};
let (want_aprs, want_hf_aprs, want_ft8, want_ft4, want_ft2, want_wspr) = bookmark_decoder_state(&bookmark);
let (want_aprs, want_hf_aprs, want_ft8, want_ft4, want_ft2, want_wspr) =
bookmark_decoder_state(&bookmark);
let desired = [
RigCommand::SetAprsDecodeEnabled(want_aprs),
RigCommand::SetHfAprsDecodeEnabled(want_hf_aprs),
@@ -57,7 +57,10 @@ fn decode_history_cutoff(context: &FrontendRuntimeContext) -> Instant {
Instant::now() - decode_history_retention(context)
}
fn prune_aprs_history(context: &FrontendRuntimeContext, history: &mut VecDeque<(Instant, AprsPacket)>) {
fn prune_aprs_history(
context: &FrontendRuntimeContext,
history: &mut VecDeque<(Instant, AprsPacket)>,
) {
let cutoff = decode_history_cutoff(context);
while let Some((ts, _)) = history.front() {
if *ts >= cutoff {
@@ -80,7 +83,10 @@ fn prune_hf_aprs_history(
}
}
fn prune_ais_history(context: &FrontendRuntimeContext, history: &mut VecDeque<(Instant, AisMessage)>) {
fn prune_ais_history(
context: &FrontendRuntimeContext,
history: &mut VecDeque<(Instant, AisMessage)>,
) {
let cutoff = decode_history_cutoff(context);
while let Some((ts, _)) = history.front() {
if *ts >= cutoff {
@@ -137,7 +143,10 @@ fn prune_cw_history(context: &FrontendRuntimeContext, history: &mut VecDeque<(In
}
}
fn prune_ft8_history(context: &FrontendRuntimeContext, history: &mut VecDeque<(Instant, Ft8Message)>) {
fn prune_ft8_history(
context: &FrontendRuntimeContext,
history: &mut VecDeque<(Instant, Ft8Message)>,
) {
let cutoff = decode_history_cutoff(context);
while let Some((ts, _)) = history.front() {
if *ts >= cutoff {
@@ -147,7 +156,10 @@ fn prune_ft8_history(context: &FrontendRuntimeContext, history: &mut VecDeque<(I
}
}
fn prune_ft4_history(context: &FrontendRuntimeContext, history: &mut VecDeque<(Instant, Ft8Message)>) {
fn prune_ft4_history(
context: &FrontendRuntimeContext,
history: &mut VecDeque<(Instant, Ft8Message)>,
) {
let cutoff = decode_history_cutoff(context);
while let Some((ts, _)) = history.front() {
if *ts >= cutoff {
@@ -157,7 +169,10 @@ fn prune_ft4_history(context: &FrontendRuntimeContext, history: &mut VecDeque<(I
}
}
fn prune_ft2_history(context: &FrontendRuntimeContext, history: &mut VecDeque<(Instant, Ft8Message)>) {
fn prune_ft2_history(
context: &FrontendRuntimeContext,
history: &mut VecDeque<(Instant, Ft8Message)>,
) {
let cutoff = decode_history_cutoff(context);
while let Some((ts, _)) = history.front() {
if *ts >= cutoff {
@@ -85,12 +85,24 @@ impl BackgroundDecodeStore {
let _ = std::fs::create_dir_all(parent);
}
let db = if path.exists() {
PickleDb::load(path, PickleDbDumpPolicy::AutoDump, SerializationMethod::Json)
.unwrap_or_else(|_| {
PickleDb::new(path, PickleDbDumpPolicy::AutoDump, SerializationMethod::Json)
})
PickleDb::load(
path,
PickleDbDumpPolicy::AutoDump,
SerializationMethod::Json,
)
.unwrap_or_else(|_| {
PickleDb::new(
path,
PickleDbDumpPolicy::AutoDump,
SerializationMethod::Json,
)
})
} else {
PickleDb::new(path, PickleDbDumpPolicy::AutoDump, SerializationMethod::Json)
PickleDb::new(
path,
PickleDbDumpPolicy::AutoDump,
SerializationMethod::Json,
)
};
Self {
db: Arc::new(RwLock::new(db)),
@@ -160,11 +172,13 @@ impl BackgroundDecodeManager {
}
pub fn get_config(&self, rig_id: &str) -> BackgroundDecodeConfig {
self.store.get(rig_id).unwrap_or_else(|| BackgroundDecodeConfig {
rig_id: rig_id.to_string(),
enabled: false,
bookmark_ids: Vec::new(),
})
self.store
.get(rig_id)
.unwrap_or_else(|| BackgroundDecodeConfig {
rig_id: rig_id.to_string(),
enabled: false,
bookmark_ids: Vec::new(),
})
}
pub fn put_config(&self, mut config: BackgroundDecodeConfig) -> Option<BackgroundDecodeConfig> {
@@ -268,10 +282,7 @@ impl BackgroundDecodeManager {
bookmark_id: bookmark.id.clone(),
freq_hz: bookmark.freq_hz,
mode: bookmark.mode.clone(),
bandwidth_hz: bookmark
.bandwidth_hz
.unwrap_or(0)
.min(u32::MAX as u64) as u32,
bandwidth_hz: bookmark.bandwidth_hz.unwrap_or(0).min(u32::MAX as u64) as u32,
decoder_kinds,
}
}
@@ -565,7 +576,8 @@ fn bookmark_supported_decoder_kinds(bookmark: &Bookmark) -> Vec<String> {
}
fn channel_matches_bookmark(channel: &ClientChannel, bookmark: &Bookmark) -> bool {
channel.freq_hz == bookmark.freq_hz && normalized_mode(&channel.mode) == normalized_mode(&bookmark.mode)
channel.freq_hz == bookmark.freq_hz
&& normalized_mode(&channel.mode) == normalized_mode(&bookmark.mode)
}
fn normalized_mode(mode: &str) -> String {
@@ -117,12 +117,24 @@ impl SchedulerStore {
let _ = std::fs::create_dir_all(parent);
}
let db = if path.exists() {
PickleDb::load(path, PickleDbDumpPolicy::AutoDump, SerializationMethod::Json)
.unwrap_or_else(|_| {
PickleDb::new(path, PickleDbDumpPolicy::AutoDump, SerializationMethod::Json)
})
PickleDb::load(
path,
PickleDbDumpPolicy::AutoDump,
SerializationMethod::Json,
)
.unwrap_or_else(|_| {
PickleDb::new(
path,
PickleDbDumpPolicy::AutoDump,
SerializationMethod::Json,
)
})
} else {
PickleDb::new(path, PickleDbDumpPolicy::AutoDump, SerializationMethod::Json)
PickleDb::new(
path,
PickleDbDumpPolicy::AutoDump,
SerializationMethod::Json,
)
};
Self {
db: Arc::new(RwLock::new(db)),
@@ -206,10 +218,8 @@ fn sunrise_sunset_today(lat_deg: f64, lon_deg: f64) -> Option<(f64, f64)> {
let lambda = sun_lon - 0.00569 - 0.00478 * omega.to_radians().sin();
// Obliquity of the ecliptic.
let eps0 = 23.0
+ (26.0
+ (21.448 - jc * (46.8150 + jc * (0.00059 - jc * 0.001813))) / 60.0)
/ 60.0;
let eps0 =
23.0 + (26.0 + (21.448 - jc * (46.8150 + jc * (0.00059 - jc * 0.001813))) / 60.0) / 60.0;
let eps = eps0 + 0.00256 * omega.to_radians().cos();
// Sun's declination.
@@ -219,8 +229,7 @@ fn sunrise_sunset_today(lat_deg: f64, lon_deg: f64) -> Option<(f64, f64)> {
let y = (eps.to_radians() / 2.0).tan().powi(2);
let l0_rad = l0.to_radians();
let eot = 4.0
* (y * (2.0 * l0_rad).sin()
- 2.0 * m_rad.sin()
* (y * (2.0 * l0_rad).sin() - 2.0 * m_rad.sin()
+ 4.0 * y * m_rad.sin() * (2.0 * l0_rad).cos()
- 0.5 * y * y * (4.0 * l0_rad).sin()
- 1.25 * (2.0 * m_rad).sin())
@@ -228,8 +237,7 @@ fn sunrise_sunset_today(lat_deg: f64, lon_deg: f64) -> Option<(f64, f64)> {
// Hour angle for sunrise/sunset (zenith = 90.833°).
let lat_rad = lat_deg.to_radians();
let cos_ha = ((PI / 2.0 + 0.833_f64.to_radians()).cos())
/ (lat_rad.cos() * decl.cos())
let cos_ha = ((PI / 2.0 + 0.833_f64.to_radians()).cos()) / (lat_rad.cos() * decl.cos())
- lat_rad.tan() * decl.tan();
if !(-1.0..=1.0).contains(&cos_ha) {
@@ -654,7 +662,10 @@ pub fn spawn_scheduler_task(
)
.await
{
warn!("scheduler: failed to apply target for '{}': {e}", config.rig_id);
warn!(
"scheduler: failed to apply target for '{}': {e}",
config.rig_id
);
continue;
}
@@ -678,7 +689,11 @@ async fn apply_scheduler_decoders(
let mut want_wspr = false;
let mut update_from = |bm: &crate::server::bookmarks::Bookmark| {
for decoder in bm.decoders.iter().map(|item| item.trim().to_ascii_lowercase()) {
for decoder in bm
.decoders
.iter()
.map(|item| item.trim().to_ascii_lowercase())
{
match decoder.as_str() {
"aprs" => want_aprs = true,
"hf-aprs" => want_hf_aprs = true,
@@ -707,7 +722,10 @@ async fn apply_scheduler_decoders(
for (label, cmd) in desired {
if let Err(e) = scheduler_send(rig_tx, cmd, rig_id.to_string()).await {
warn!("scheduler: Set{label}DecodeEnabled failed for '{}': {:?}", rig_id, e);
warn!(
"scheduler: Set{label}DecodeEnabled failed for '{}': {:?}",
rig_id, e
);
}
}
}
@@ -931,7 +949,9 @@ pub async fn put_scheduler_control(
#[cfg(test)]
mod tests {
use super::{timespan_active_entry, timespan_cycle_slot, timespan_active_entries, ScheduleEntry};
use super::{
timespan_active_entries, timespan_active_entry, timespan_cycle_slot, ScheduleEntry,
};
fn entry(
id: &str,
@@ -6,10 +6,10 @@
mod api;
#[path = "audio.rs"]
pub mod audio;
#[path = "background_decode.rs"]
pub mod background_decode;
#[path = "auth.rs"]
pub mod auth;
#[path = "background_decode.rs"]
pub mod background_decode;
#[path = "bookmarks.rs"]
pub mod bookmarks;
#[path = "scheduler.rs"]
@@ -88,8 +88,7 @@ async fn serve(
);
let background_decode_path = BackgroundDecodeStore::default_path();
let background_decode_store =
Arc::new(BackgroundDecodeStore::open(&background_decode_path));
let background_decode_store = Arc::new(BackgroundDecodeStore::open(&background_decode_path));
let vchan_mgr = Arc::new(ClientChannelManager::new(4));
let background_decode_mgr = BackgroundDecodeManager::new(
background_decode_store,
@@ -9,8 +9,7 @@ const CLIENT_BUILD_DATE: &str = env!("TRX_CLIENT_BUILD_DATE");
const INDEX_HTML: &str = include_str!("../assets/web/index.html");
pub const STYLE_CSS: &str = include_str!("../assets/web/style.css");
pub const APP_JS: &str = include_str!("../assets/web/app.js");
pub const DECODE_HISTORY_WORKER_JS: &str =
include_str!("../assets/web/decode-history-worker.js");
pub const DECODE_HISTORY_WORKER_JS: &str = include_str!("../assets/web/decode-history-worker.js");
pub const WEBGL_RENDERER_JS: &str = include_str!("../assets/web/webgl-renderer.js");
pub const LEAFLET_AIS_TRACKSYMBOL_JS: &str =
include_str!("../assets/web/leaflet-ais-tracksymbol.js");
@@ -25,8 +24,7 @@ pub const WSPR_JS: &str = include_str!("../assets/web/plugins/wspr.js");
pub const CW_JS: &str = include_str!("../assets/web/plugins/cw.js");
pub const BOOKMARKS_JS: &str = include_str!("../assets/web/plugins/bookmarks.js");
pub const SCHEDULER_JS: &str = include_str!("../assets/web/plugins/scheduler.js");
pub const BACKGROUND_DECODE_JS: &str =
include_str!("../assets/web/plugins/background-decode.js");
pub const BACKGROUND_DECODE_JS: &str = include_str!("../assets/web/plugins/background-decode.js");
pub const VCHAN_JS: &str = include_str!("../assets/web/plugins/vchan.js");
pub fn index_html() -> String {
@@ -367,11 +367,7 @@ impl ClientChannelManager {
}
/// Explicitly delete a channel by UUID (any session may do this).
pub fn delete_channel(
&self,
rig_id: &str,
channel_id: Uuid,
) -> Result<(), VChanClientError> {
pub fn delete_channel(&self, rig_id: &str, channel_id: Uuid) -> Result<(), VChanClientError> {
let mut rigs = self.rigs.write().unwrap();
let channels = rigs.get_mut(rig_id).ok_or(VChanClientError::NotFound)?;
let pos = channels
@@ -450,7 +446,10 @@ impl ClientChannelManager {
ch.freq_hz = freq_hz;
self.broadcast_change(rig_id, channels);
drop(rigs);
self.send_audio_cmd(VChanAudioCmd::SetFreq { uuid: channel_id, freq_hz });
self.send_audio_cmd(VChanAudioCmd::SetFreq {
uuid: channel_id,
freq_hz,
});
Ok(())
}
@@ -469,7 +468,10 @@ impl ClientChannelManager {
ch.mode = mode.to_string();
self.broadcast_change(rig_id, channels);
drop(rigs);
self.send_audio_cmd(VChanAudioCmd::SetMode { uuid: channel_id, mode: mode.to_string() });
self.send_audio_cmd(VChanAudioCmd::SetMode {
uuid: channel_id,
mode: mode.to_string(),
});
Ok(())
}
@@ -488,7 +490,10 @@ impl ClientChannelManager {
ch.bandwidth_hz = bandwidth_hz;
self.broadcast_change(rig_id, channels);
drop(rigs);
self.send_audio_cmd(VChanAudioCmd::SetBandwidth { uuid: channel_id, bandwidth_hz });
self.send_audio_cmd(VChanAudioCmd::SetBandwidth {
uuid: channel_id,
bandwidth_hz,
});
Ok(())
}
@@ -530,12 +535,14 @@ impl ClientChannelManager {
let mut changed = false;
let desired_map: HashMap<String, (u64, String, u32, Vec<String>)> = desired
.iter()
.map(|(bookmark_id, freq_hz, mode, bandwidth_hz, decoder_kinds)| {
(
bookmark_id.clone(),
(*freq_hz, mode.clone(), *bandwidth_hz, decoder_kinds.clone()),
)
})
.map(
|(bookmark_id, freq_hz, mode, bandwidth_hz, decoder_kinds)| {
(
bookmark_id.clone(),
(*freq_hz, mode.clone(), *bandwidth_hz, decoder_kinds.clone()),
)
},
)
.collect();
let desired_ids: std::collections::HashSet<&str> =
desired_map.keys().map(String::as_str).collect();
@@ -561,7 +568,8 @@ impl ClientChannelManager {
let Some(bookmark_id) = channel.scheduler_bookmark_id.as_deref() else {
continue;
};
let Some((freq_hz, mode, bandwidth_hz, decoder_kinds)) = desired_map.get(bookmark_id) else {
let Some((freq_hz, mode, bandwidth_hz, decoder_kinds)) = desired_map.get(bookmark_id)
else {
continue;
};
if channel.freq_hz != *freq_hz {