refactor: use CompactString for formatting in Proxy conversion and TUI drawing
This commit is contained in:
+9
-6
@@ -65,12 +65,15 @@ impl TryFrom<&mut Proxy> for reqwest::Proxy {
|
||||
|
||||
#[inline]
|
||||
fn try_from(value: &mut Proxy) -> Result<Self, Self::Error> {
|
||||
let proxy = Self::all(format!(
|
||||
"{}://{}:{}",
|
||||
value.protocol.as_str(),
|
||||
value.host,
|
||||
value.port
|
||||
))?;
|
||||
let proxy = Self::all(
|
||||
compact_str::format_compact!(
|
||||
"{}://{}:{}",
|
||||
value.protocol.as_str(),
|
||||
value.host,
|
||||
value.port
|
||||
)
|
||||
.as_str(),
|
||||
)?;
|
||||
|
||||
if let (Some(username), Some(password)) =
|
||||
(value.username.as_ref(), value.password.as_ref())
|
||||
|
||||
+11
-8
@@ -272,14 +272,17 @@ fn draw(f: &mut Frame<'_>, state: &AppState, logger_state: &TuiWidgetState) {
|
||||
let proxies_working =
|
||||
state.proxies_working.get(proxy_type).copied().unwrap_or_default();
|
||||
f.render_widget(
|
||||
Line::from(format!("{} ({:.1}%)", proxies_working, {
|
||||
if proxies_checked == 0 {
|
||||
0.0_f64
|
||||
} else {
|
||||
(proxies_working as f64) / (proxies_checked as f64)
|
||||
* 100.0_f64
|
||||
}
|
||||
}))
|
||||
Line::from(
|
||||
compact_str::format_compact!("{} ({:.1}%)", proxies_working, {
|
||||
if proxies_checked == 0 {
|
||||
0.0_f64
|
||||
} else {
|
||||
(proxies_working as f64) / (proxies_checked as f64)
|
||||
* 100.0_f64
|
||||
}
|
||||
})
|
||||
.as_str(),
|
||||
)
|
||||
.alignment(Alignment::Center),
|
||||
working_proxies_block.inner(layout[2]),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user