refactor: rename proxy.as_str to proxy.to_string for clarity
This commit is contained in:
+1
-1
@@ -58,7 +58,7 @@ pub async fn check_all<R: reqwest::dns::Resolve + 'static>(
|
||||
Err(e) if tracing::event_enabled!(tracing::Level::DEBUG) => {
|
||||
tracing::debug!(
|
||||
"{} | {}",
|
||||
proxy.as_str(true),
|
||||
proxy.to_string(true),
|
||||
pretty_error(&e)
|
||||
);
|
||||
}
|
||||
|
||||
+1
-1
@@ -240,6 +240,6 @@ where
|
||||
{
|
||||
proxies
|
||||
.into_iter()
|
||||
.map(move |proxy| proxy.as_str(include_protocol))
|
||||
.map(move |proxy| proxy.to_string(include_protocol))
|
||||
.join("\n")
|
||||
}
|
||||
|
||||
+7
-2
@@ -1,4 +1,5 @@
|
||||
use std::{
|
||||
fmt::Write as _,
|
||||
hash::{Hash, Hasher},
|
||||
str::FromStr,
|
||||
sync::Arc,
|
||||
@@ -131,12 +132,14 @@ impl Proxy {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn as_str(&self, include_protocol: bool) -> String {
|
||||
pub fn to_string(&self, include_protocol: bool) -> String {
|
||||
let mut s = String::new();
|
||||
|
||||
if include_protocol {
|
||||
s.push_str(self.protocol.as_str());
|
||||
s.push_str("://");
|
||||
}
|
||||
|
||||
if let (Some(username), Some(password)) =
|
||||
(&self.username, &self.password)
|
||||
{
|
||||
@@ -145,9 +148,11 @@ impl Proxy {
|
||||
s.push_str(password);
|
||||
s.push('@');
|
||||
}
|
||||
|
||||
s.push_str(&self.host);
|
||||
s.push(':');
|
||||
s.push_str(&self.port.to_string());
|
||||
write!(s, "{}", self.port).unwrap();
|
||||
|
||||
s
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user