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
+3 -3
View File
@@ -1,7 +1,7 @@
use crate::models::FileDisplayData;
use crate::ui::{
HIGHLIGHT_SYMBOL, border_style, border_type, format_bytes, header_style,
highlight_style,
BYTES_PER_MB, HIGHLIGHT_SYMBOL, border_style, border_type, format_bytes,
header_style, highlight_style,
};
use ratatui::{
Frame,
@@ -96,7 +96,7 @@ No results. Select a search from the Searches pane [1]. Or start new search [s
let speed_str = if file.speed > 0 {
let speed_mb =
(file.speed as f64 / 1_048_576.0 * 100.0).round() / 100.0;
(file.speed as f64 / BYTES_PER_MB * 100.0).round() / 100.0;
format!("{} MB/s", speed_mb)
} else {
"-".to_string()