fix clippy errors

This commit is contained in:
monosans
2026-05-28 08:21:50 +03:00
parent acb6d4e4a0
commit 3ce7070d84
6 changed files with 48 additions and 25 deletions
+5 -2
View File
@@ -6,14 +6,17 @@ use color_eyre::eyre::OptionExt as _;
use crate::event::{AppEvent, Event};
use crate::{config::Config, proxy::Proxy, utils::pretty_error};
pub async fn check_all<R: reqwest::dns::Resolve + Clone + 'static>(
pub async fn check_all<R>(
config: Arc<Config>,
dns_resolver: R,
proxies: Vec<Proxy>,
mut tls_backend: rustls::ClientConfig,
token: tokio_util::sync::CancellationToken,
#[cfg(feature = "tui")] tx: tokio::sync::mpsc::UnboundedSender<Event>,
) -> crate::Result<Vec<Proxy>> {
) -> crate::Result<Vec<Proxy>>
where
R: reqwest::dns::Resolve + Clone + 'static,
{
if config.checking.check_url.is_none() {
return Ok(proxies);
}
+5 -2
View File
@@ -181,11 +181,14 @@ impl reqwest_middleware::Middleware for RetryMiddleware {
}
}
pub fn create_reqwest_client<R: reqwest::dns::Resolve + 'static>(
pub fn create_reqwest_client<R>(
config: &Config,
dns_resolver: R,
mut tls_backend: rustls::ClientConfig,
) -> crate::Result<reqwest_middleware::ClientWithMiddleware> {
) -> crate::Result<reqwest_middleware::ClientWithMiddleware>
where
R: reqwest::dns::Resolve + 'static,
{
tls_backend.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()];
let mut builder = reqwest::ClientBuilder::new()
.user_agent(config.scraping.user_agent.as_bytes())
+6 -2
View File
@@ -61,10 +61,14 @@ fn strip_non_english_names(v: &mut serde_json::Value) {
}
#[expect(clippy::ref_option)]
fn serialize_opt_strip_names<T: serde::Serialize, S: serde::Serializer>(
fn serialize_opt_strip_names<T, S>(
opt: &Option<T>,
serializer: S,
) -> Result<S::Ok, S::Error> {
) -> Result<S::Ok, S::Error>
where
T: serde::Serialize,
S: serde::Serializer,
{
if let Some(t) = opt {
let mut v =
serde_json::to_value(t).map_err(serde::ser::Error::custom)?;
+13 -8
View File
@@ -119,12 +119,15 @@ impl ProxySink for Vec<u8> {
}
impl Proxy {
pub async fn check<R: reqwest::dns::Resolve + 'static>(
pub async fn check<R>(
&mut self,
config: &Config,
dns_resolver: R,
tls_backend: rustls::ClientConfig,
) -> crate::Result<()> {
) -> crate::Result<()>
where
R: reqwest::dns::Resolve + 'static,
{
let Some(check_url) = config.checking.check_url.clone() else {
return Ok(());
};
@@ -161,11 +164,10 @@ impl Proxy {
Ok(())
}
pub fn write_to_sink<S: ProxySink>(
&self,
sink: &mut S,
include_protocol: bool,
) {
pub fn write_to_sink<S>(&self, sink: &mut S, include_protocol: bool)
where
S: ProxySink,
{
if include_protocol {
sink.push_str(self.protocol.as_str_lowercase());
sink.push_str("://");
@@ -208,7 +210,10 @@ impl PartialEq for Proxy {
#[expect(clippy::missing_trait_methods)]
impl Hash for Proxy {
fn hash<H: Hasher>(&self, state: &mut H) {
fn hash<H>(&self, state: &mut H)
where
H: Hasher,
{
self.protocol.hash(state);
self.host.hash(state);
self.port.hash(state);
+18 -10
View File
@@ -11,9 +11,10 @@ use crate::{HashMap, http::BasicAuth};
const CONFIG_ENV: &str = "PROXY_SCRAPER_CHECKER_CONFIG";
fn validate_positive_f64<'de, D: serde::Deserializer<'de>>(
deserializer: D,
) -> Result<f64, D::Error> {
fn validate_positive_f64<'de, D>(deserializer: D) -> Result<f64, D::Error>
where
D: serde::Deserializer<'de>,
{
let val = f64::deserialize(deserializer)?;
if val > 0.0 {
Ok(val)
@@ -67,15 +68,21 @@ where
}
}
fn validate_proxy_url<'de, D: serde::Deserializer<'de>>(
fn validate_proxy_url<'de, D>(
deserializer: D,
) -> Result<Option<url::Url>, D::Error> {
) -> Result<Option<url::Url>, D::Error>
where
D: serde::Deserializer<'de>,
{
validate_url_generic(deserializer, &["http", "https", "socks4", "socks5"])
}
fn validate_http_url<'de, D: serde::Deserializer<'de>>(
fn validate_http_url<'de, D>(
deserializer: D,
) -> Result<Option<url::Url>, D::Error> {
) -> Result<Option<url::Url>, D::Error>
where
D: serde::Deserializer<'de>,
{
validate_url_generic(deserializer, &["http", "https"])
}
@@ -159,9 +166,10 @@ pub struct RawConfig {
#[expect(clippy::missing_trait_methods)]
impl<'de> serde::Deserialize<'de> for OutputConfig {
fn deserialize<D: serde::Deserializer<'de>>(
deserializer: D,
) -> Result<Self, D::Error> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
#[derive(serde::Deserialize)]
struct InnerOutputConfig {
pub path: PathBuf,
+1 -1
View File
@@ -24,7 +24,7 @@ pub trait CompactStrJoin: Iterator {
}
#[expect(clippy::missing_trait_methods)]
impl<T: Iterator> CompactStrJoin for T {}
impl<T> CompactStrJoin for T where T: Iterator {}
pub fn pretty_error(e: &crate::Error) -> compact_str::CompactString {
e.chain().join(" \u{2192} ")