mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-03 01:39:28 +02:00
Chore: fix clippy warnings for stable (1.87) and nightly (1.89) (#1504)
* chore: stable - fix clippy warnings * chore: nightly - fix clippy warnings
This commit is contained in:
parent
8b729540f4
commit
3686718ea2
6 changed files with 13 additions and 19 deletions
|
@ -57,7 +57,7 @@ impl std::fmt::Display for MercuryMethod {
|
||||||
MercuryMethod::Unsub => "UNSUB",
|
MercuryMethod::Unsub => "UNSUB",
|
||||||
MercuryMethod::Send => "SEND",
|
MercuryMethod::Send => "SEND",
|
||||||
};
|
};
|
||||||
write!(f, "{}", s)
|
write!(f, "{s}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub async fn proxy_connect<T: AsyncRead + AsyncWrite + Unpin>(
|
||||||
loop {
|
loop {
|
||||||
let bytes_read = proxy_connection.read(&mut buffer[offset..]).await?;
|
let bytes_read = proxy_connection.read(&mut buffer[offset..]).await?;
|
||||||
if bytes_read == 0 {
|
if bytes_read == 0 {
|
||||||
return Err(io::Error::new(io::ErrorKind::Other, "Early EOF from proxy"));
|
return Err(io::Error::other("Early EOF from proxy"));
|
||||||
}
|
}
|
||||||
offset += bytes_read;
|
offset += bytes_read;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ pub async fn proxy_connect<T: AsyncRead + AsyncWrite + Unpin>(
|
||||||
|
|
||||||
let status = response
|
let status = response
|
||||||
.parse(&buffer[..offset])
|
.parse(&buffer[..offset])
|
||||||
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
|
.map_err(io::Error::other)?;
|
||||||
|
|
||||||
if status.is_complete() {
|
if status.is_complete() {
|
||||||
return match response.code {
|
return match response.code {
|
||||||
|
@ -39,12 +39,9 @@ pub async fn proxy_connect<T: AsyncRead + AsyncWrite + Unpin>(
|
||||||
Some(code) => {
|
Some(code) => {
|
||||||
let reason = response.reason.unwrap_or("no reason");
|
let reason = response.reason.unwrap_or("no reason");
|
||||||
let msg = format!("Proxy responded with {code}: {reason}");
|
let msg = format!("Proxy responded with {code}: {reason}");
|
||||||
Err(io::Error::new(io::ErrorKind::Other, msg))
|
Err(io::Error::other(msg))
|
||||||
}
|
}
|
||||||
None => Err(io::Error::new(
|
None => Err(io::Error::other("Malformed response from proxy")),
|
||||||
io::ErrorKind::Other,
|
|
||||||
"Malformed response from proxy",
|
|
||||||
)),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,12 +96,10 @@ pub fn find(name: Option<&str>) -> Result<DnsSdServiceBuilder, Error> {
|
||||||
match BACKENDS.iter().find(|(id, _)| name == id) {
|
match BACKENDS.iter().find(|(id, _)| name == id) {
|
||||||
Some((_id, Some(launch_svc))) => Ok(*launch_svc),
|
Some((_id, Some(launch_svc))) => Ok(*launch_svc),
|
||||||
Some((_id, None)) => Err(Error::unavailable(format!(
|
Some((_id, None)) => Err(Error::unavailable(format!(
|
||||||
"librespot built without '{}' support",
|
"librespot built without '{name}' support"
|
||||||
name
|
|
||||||
))),
|
))),
|
||||||
None => Err(Error::not_found(format!(
|
None => Err(Error::not_found(format!(
|
||||||
"unknown zeroconf backend '{}'",
|
"unknown zeroconf backend '{name}'"
|
||||||
name
|
|
||||||
))),
|
))),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -286,14 +284,14 @@ async fn avahi_task(
|
||||||
//
|
//
|
||||||
// EntryGroup has been withdrawn at this point already!
|
// EntryGroup has been withdrawn at this point already!
|
||||||
log::error!("zeroconf collision for name '{}'", &name);
|
log::error!("zeroconf collision for name '{}'", &name);
|
||||||
return Err(zbus::Error::Failure(format!("zeroconf collision for name: {}", name)).into());
|
return Err(zbus::Error::Failure(format!("zeroconf collision for name: {name}")).into());
|
||||||
}
|
}
|
||||||
EntryGroupState::Failure => {
|
EntryGroupState::Failure => {
|
||||||
// TODO: Back off/treat as fatal?
|
// TODO: Back off/treat as fatal?
|
||||||
// EntryGroup has been withdrawn at this point already!
|
// EntryGroup has been withdrawn at this point already!
|
||||||
// There seems to be no code in Avahi that actually sets this state.
|
// There seems to be no code in Avahi that actually sets this state.
|
||||||
log::error!("zeroconf failure: {}", error);
|
log::error!("zeroconf failure: {}", error);
|
||||||
return Err(zbus::Error::Failure(format!("zeroconf failure: {}", error)).into());
|
return Err(zbus::Error::Failure(format!("zeroconf failure: {error}")).into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ impl OAuthClient {
|
||||||
if self.should_open_url {
|
if self.should_open_url {
|
||||||
open::that_in_background(auth_url.as_str());
|
open::that_in_background(auth_url.as_str());
|
||||||
}
|
}
|
||||||
println!("Browse to: {}", auth_url);
|
println!("Browse to: {auth_url}");
|
||||||
|
|
||||||
pkce_verifier
|
pkce_verifier
|
||||||
}
|
}
|
||||||
|
@ -456,7 +456,7 @@ pub fn get_access_token(
|
||||||
.set_pkce_challenge(pkce_challenge)
|
.set_pkce_challenge(pkce_challenge)
|
||||||
.url();
|
.url();
|
||||||
|
|
||||||
println!("Browse to: {}", auth_url);
|
println!("Browse to: {auth_url}");
|
||||||
|
|
||||||
let code = match get_socket_address(redirect_uri) {
|
let code = match get_socket_address(redirect_uri) {
|
||||||
Some(addr) => get_authcode_listener(addr, String::from("Go back to your terminal :)")),
|
Some(addr) => get_authcode_listener(addr, String::from("Go back to your terminal :)")),
|
||||||
|
|
|
@ -158,6 +158,6 @@ impl CubicMapping {
|
||||||
fn min_norm(db_range: f64) -> f64 {
|
fn min_norm(db_range: f64) -> f64 {
|
||||||
// Note that this 60.0 is unrelated to DEFAULT_DB_RANGE.
|
// Note that this 60.0 is unrelated to DEFAULT_DB_RANGE.
|
||||||
// Instead, it's the cubic voltage to dB ratio.
|
// Instead, it's the cubic voltage to dB ratio.
|
||||||
f64::powf(10.0, -1.0 * db_range / 60.0)
|
f64::powf(10.0, -db_range / 60.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1227,8 +1227,7 @@ fn get_setup() -> Setup {
|
||||||
Some("librespot compiled without zeroconf backend".to_owned())
|
Some("librespot compiled without zeroconf backend".to_owned())
|
||||||
} else if opt_present(DISABLE_DISCOVERY) {
|
} else if opt_present(DISABLE_DISCOVERY) {
|
||||||
Some(format!(
|
Some(format!(
|
||||||
"the `--{}` / `-{}` flag set",
|
"the `--{DISABLE_DISCOVERY}` / `-{DISABLE_DISCOVERY_SHORT}` flag set",
|
||||||
DISABLE_DISCOVERY, DISABLE_DISCOVERY_SHORT,
|
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue