refactor: centralize BYTES_PER_MB and tidy peer IP parsing

- Add pub const BYTES_PER_MB to ui/utils.rs and replace 7 uses of the
  bare 1_048_576.0 literal across the UI modules. Also pick up
  uninlined-format-args cleanup in the same file while we're here.
- Replace Vec<i32> IP-byte accumulator in Peer::new_from_message with a
  [u8; 4]; the .abs() calls on u8.into() were no-ops on always-positive
  values. Network byte order ([3].[2].[1].[0]) preserved; tests cover
  the wire format.
This commit is contained in:
michel
2026-04-26 17:20:45 +02:00
parent e0218b2433
commit 9d6a33da34
5 changed files with 32 additions and 36 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
use crate::models::FileDisplayData;
use crate::ui::{
HIGHLIGHT_SYMBOL, border_style, border_type, format_bytes,
BYTES_PER_MB, HIGHLIGHT_SYMBOL, border_style, border_type, format_bytes,
format_shortcuts_styled, get_bitrate, get_spinner_char, header_style,
highlight_style, primary_style, success_style, warning_style,
};
@@ -379,7 +379,7 @@ impl FileSelector {
let is_selected = self.selected_indices.contains(&original_idx);
let checkbox = if is_selected { "[✓]" } else { "[ ]" };
let speed_mb = item.speed as f64 / 1_048_576.0;
let speed_mb = item.speed as f64 / BYTES_PER_MB;
let speed_str = if speed_mb > 0.0 {
format!("{:.1} MB/s", speed_mb)
} else {