style: apply cargo fmt across the crate (A20)
The repo never enforced rustfmt, so formatting had drifted broadly. This is a single mechanical `cargo fmt` pass over the whole crate (no behavioral change; lib suite green, 493 passed). Going forward fmt should be enforced (planned CI fmt --check step). Part of the 0.6.1 hygiene pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+44
-17
@@ -27,8 +27,11 @@ pub enum NetworkMode {
|
||||
|
||||
impl NetworkMode {
|
||||
/// All variants, for presentation in a picker.
|
||||
pub const ALL: [NetworkMode; 3] =
|
||||
[NetworkMode::RelayNoDiscovery, NetworkMode::N0Full, NetworkMode::DirectOnly];
|
||||
pub const ALL: [NetworkMode; 3] = [
|
||||
NetworkMode::RelayNoDiscovery,
|
||||
NetworkMode::N0Full,
|
||||
NetworkMode::DirectOnly,
|
||||
];
|
||||
}
|
||||
|
||||
/// Arrangement of the in-call room screen, chosen via the layout picker.
|
||||
@@ -45,8 +48,11 @@ pub enum RoomLayout {
|
||||
|
||||
impl RoomLayout {
|
||||
/// All variants, in picker display order.
|
||||
pub const ALL: [RoomLayout; 3] =
|
||||
[RoomLayout::ThreeColumn, RoomLayout::BottomDock, RoomLayout::Drawer];
|
||||
pub const ALL: [RoomLayout; 3] = [
|
||||
RoomLayout::ThreeColumn,
|
||||
RoomLayout::BottomDock,
|
||||
RoomLayout::Drawer,
|
||||
];
|
||||
}
|
||||
|
||||
/// What a call recording captures. `Mixed` is the original single-file behaviour;
|
||||
@@ -65,8 +71,11 @@ pub enum RecordingMode {
|
||||
|
||||
impl RecordingMode {
|
||||
/// All variants, in picker display order.
|
||||
pub const ALL: [RecordingMode; 3] =
|
||||
[RecordingMode::Mixed, RecordingMode::Multitrack, RecordingMode::Both];
|
||||
pub const ALL: [RecordingMode; 3] = [
|
||||
RecordingMode::Mixed,
|
||||
RecordingMode::Multitrack,
|
||||
RecordingMode::Both,
|
||||
];
|
||||
|
||||
/// True when this mode writes per-peer stem tracks (Multitrack or Both).
|
||||
pub fn is_multitrack(self) -> bool {
|
||||
@@ -707,7 +716,10 @@ mod tests {
|
||||
|
||||
assert_eq!(deserialized.network_mode, NetworkMode::RelayNoDiscovery);
|
||||
// Configs predating the presence posture load as friends-only (no beacon).
|
||||
assert_eq!(deserialized.presence_mode, crate::presence::PresenceMode::Normal);
|
||||
assert_eq!(
|
||||
deserialized.presence_mode,
|
||||
crate::presence::PresenceMode::Normal
|
||||
);
|
||||
assert!(!deserialized.echo_cancellation_enabled);
|
||||
assert!(deserialized.notifications_enabled);
|
||||
// Configs predating the volume sliders must load at unity gain.
|
||||
@@ -735,7 +747,10 @@ mod tests {
|
||||
// Configs predating the per-sound flags (W6) enable every chime, so an
|
||||
// upgrade is silent-change-free.
|
||||
for sound in Sound::ALL {
|
||||
assert!(deserialized.sound_enabled(sound), "{sound:?} should default on");
|
||||
assert!(
|
||||
deserialized.sound_enabled(sound),
|
||||
"{sound:?} should default on"
|
||||
);
|
||||
}
|
||||
// The accessor and mutator agree round-trip.
|
||||
let mut cfg = AppConfig::default();
|
||||
@@ -782,7 +797,10 @@ mod tests {
|
||||
}"#;
|
||||
let cfg: AppConfig = serde_json::from_str(legacy_json).unwrap();
|
||||
// The pre-existing single background survives untouched (still Option<String>).
|
||||
assert_eq!(cfg.background.as_deref(), Some("/home/eric/.config/peerspeak/background.png"));
|
||||
assert_eq!(
|
||||
cfg.background.as_deref(),
|
||||
Some("/home/eric/.config/peerspeak/background.png")
|
||||
);
|
||||
assert!((cfg.background_dim - 0.4).abs() < f32::EPSILON);
|
||||
// The new game-detection fields default to off/empty → silent, opt-in upgrade.
|
||||
assert!(!cfg.game_presence_enabled);
|
||||
@@ -794,9 +812,12 @@ mod tests {
|
||||
fn test_game_maps_serialize_deterministically() {
|
||||
// BTreeMap ordering makes the serialized config stable across runs.
|
||||
let mut cfg = AppConfig::default();
|
||||
cfg.game_backgrounds.insert("steam:730".into(), "/a.png".into());
|
||||
cfg.game_backgrounds.insert("exe:hl2_linux".into(), "/b.png".into());
|
||||
cfg.game_process_map.insert("hl2_linux".into(), "Half-Life 2".into());
|
||||
cfg.game_backgrounds
|
||||
.insert("steam:730".into(), "/a.png".into());
|
||||
cfg.game_backgrounds
|
||||
.insert("exe:hl2_linux".into(), "/b.png".into());
|
||||
cfg.game_process_map
|
||||
.insert("hl2_linux".into(), "Half-Life 2".into());
|
||||
let json = serde_json::to_string(&cfg).unwrap();
|
||||
// Keys appear in sorted order (exe: before steam:).
|
||||
let bg = json.find("game_backgrounds").unwrap();
|
||||
@@ -854,8 +875,7 @@ mod tests {
|
||||
recording_mode: RecordingMode::Both,
|
||||
..AppConfig::default()
|
||||
};
|
||||
let back: AppConfig =
|
||||
serde_json::from_str(&serde_json::to_string(&cfg).unwrap()).unwrap();
|
||||
let back: AppConfig = serde_json::from_str(&serde_json::to_string(&cfg).unwrap()).unwrap();
|
||||
assert_eq!(back.recording_mode, RecordingMode::Both);
|
||||
// is_multitrack() classifies correctly.
|
||||
assert!(!RecordingMode::Mixed.is_multitrack());
|
||||
@@ -941,7 +961,10 @@ mod tests {
|
||||
assert_eq!(round_tripped.input_volume, 1.5);
|
||||
assert_eq!(round_tripped.output_volume, 0.25);
|
||||
assert_eq!(round_tripped.clip_volume, 0.7);
|
||||
assert_eq!(round_tripped.music_playlist, vec!["/tmp/song.ogg".to_string()]);
|
||||
assert_eq!(
|
||||
round_tripped.music_playlist,
|
||||
vec!["/tmp/song.ogg".to_string()]
|
||||
);
|
||||
assert_eq!(round_tripped.music_volume, 0.6);
|
||||
assert!(round_tripped.music_broadcast);
|
||||
assert!(!round_tripped.show_player_bar);
|
||||
@@ -950,7 +973,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_notifications_enabled_specifically() {
|
||||
let missing_notifications = r#"{"input_device":"","output_device":"","noise_gate_threshold":0.01}"#;
|
||||
let missing_notifications =
|
||||
r#"{"input_device":"","output_device":"","noise_gate_threshold":0.01}"#;
|
||||
let config_missing: AppConfig = serde_json::from_str(missing_notifications).unwrap();
|
||||
assert!(config_missing.notifications_enabled);
|
||||
|
||||
@@ -1009,7 +1033,10 @@ mod tests {
|
||||
|
||||
// Assert that deserialization succeeds even with unrecognized/unknown fields.
|
||||
// This confirms that serde does not reject unknown fields (i.e. default behavior).
|
||||
assert!(deserialized_res.is_ok(), "Config deserialization failed when an unknown field was present");
|
||||
assert!(
|
||||
deserialized_res.is_ok(),
|
||||
"Config deserialization failed when an unknown field was present"
|
||||
);
|
||||
|
||||
let config = deserialized_res.unwrap();
|
||||
assert_eq!(config.input_device, "");
|
||||
|
||||
Reference in New Issue
Block a user