Fix clippy lints

This commit is contained in:
Roderick van Domburg 2022-05-21 21:36:56 +02:00
parent 3d298768b3
commit 2a3e248bba
No known key found for this signature in database
GPG key ID: A9EF5222A26F0451
7 changed files with 30 additions and 40 deletions

View file

@ -8,17 +8,14 @@ fn main() {
flags.toggle(ConstantsFlags::REBUILD_ON_HEAD_CHANGE); flags.toggle(ConstantsFlags::REBUILD_ON_HEAD_CHANGE);
generate_cargo_keys(ConstantsFlags::all()).expect("Unable to generate the cargo keys!"); generate_cargo_keys(ConstantsFlags::all()).expect("Unable to generate the cargo keys!");
let build_id: String; let build_id = match env::var("SOURCE_DATE_EPOCH") {
match env::var("SOURCE_DATE_EPOCH") { Ok(val) => val,
Ok(val) => build_id = val, Err(_) => rand::thread_rng()
Err(_) => {
build_id = rand::thread_rng()
.sample_iter(Alphanumeric) .sample_iter(Alphanumeric)
.take(8) .take(8)
.map(char::from) .map(char::from)
.collect() .collect(),
} };
}
println!("cargo:rustc-env=LIBRESPOT_BUILD_ID={}", build_id); println!("cargo:rustc-env=LIBRESPOT_BUILD_ID={}", build_id);
} }

View file

@ -10,7 +10,6 @@ edition = "2018"
[dependencies] [dependencies]
aes-ctr = "0.6" aes-ctr = "0.6"
base64 = "0.13" base64 = "0.13"
cfg-if = "1.0"
form_urlencoded = "1.0" form_urlencoded = "1.0"
futures-core = "0.3" futures-core = "0.3"
hmac = "0.11" hmac = "0.11"

View file

@ -16,7 +16,6 @@ use std::io;
use std::pin::Pin; use std::pin::Pin;
use std::task::{Context, Poll}; use std::task::{Context, Poll};
use cfg_if::cfg_if;
use futures_core::Stream; use futures_core::Stream;
use librespot_core as core; use librespot_core as core;
use thiserror::Error; use thiserror::Error;
@ -100,29 +99,24 @@ impl Builder {
let name = self.server_config.name.clone().into_owned(); let name = self.server_config.name.clone().into_owned();
let server = DiscoveryServer::new(self.server_config, &mut port)?; let server = DiscoveryServer::new(self.server_config, &mut port)?;
let svc; #[cfg(feature = "with-dns-sd")]
let svc = dns_sd::DNSService::register(
cfg_if! {
if #[cfg(feature = "with-dns-sd")] {
svc = dns_sd::DNSService::register(
Some(name.as_ref()), Some(name.as_ref()),
"_spotify-connect._tcp", "_spotify-connect._tcp",
None, None,
None, None,
port, port,
&["VERSION=1.0", "CPath=/"], &["VERSION=1.0", "CPath=/"],
).map_err(|e| Error::DnsSdError(io::Error::new(io::ErrorKind::Unsupported, e)))?; )
.map_err(|e| Error::DnsSdError(io::Error::new(io::ErrorKind::Unsupported, e)))?;
} else { #[cfg(not(feature = "with-dns-sd"))]
let responder = libmdns::Responder::spawn(&tokio::runtime::Handle::current())?; let svc = libmdns::Responder::spawn(&tokio::runtime::Handle::current())?.register(
svc = responder.register(
"_spotify-connect._tcp".to_owned(), "_spotify-connect._tcp".to_owned(),
name, name,
port, port,
&["VERSION=1.0", "CPath=/"], &["VERSION=1.0", "CPath=/"],
) );
}
};
Ok(Discovery { server, _svc: svc }) Ok(Discovery { server, _svc: svc })
} }

View file

@ -191,7 +191,7 @@ impl Mixer for AlsaMixer {
mapped_volume = LogMapping::linear_to_mapped(mapped_volume, self.db_range); mapped_volume = LogMapping::linear_to_mapped(mapped_volume, self.db_range);
} }
self.config.volume_ctrl.from_mapped(mapped_volume) self.config.volume_ctrl.to_unmapped(mapped_volume)
} }
fn set_volume(&self, volume: u16) { fn set_volume(&self, volume: u16) {

View file

@ -3,7 +3,7 @@ use crate::player::db_to_ratio;
pub trait MappedCtrl { pub trait MappedCtrl {
fn to_mapped(&self, volume: u16) -> f64; fn to_mapped(&self, volume: u16) -> f64;
fn from_mapped(&self, mapped_volume: f64) -> u16; fn to_unmapped(&self, mapped_volume: f64) -> u16;
fn db_range(&self) -> f64; fn db_range(&self) -> f64;
fn set_db_range(&mut self, new_db_range: f64); fn set_db_range(&mut self, new_db_range: f64);
@ -49,7 +49,7 @@ impl MappedCtrl for VolumeCtrl {
mapped_volume mapped_volume
} }
fn from_mapped(&self, mapped_volume: f64) -> u16 { fn to_unmapped(&self, mapped_volume: f64) -> u16 {
// More than just an optimization, this ensures that zero mapped volume // More than just an optimization, this ensures that zero mapped volume
// is unmapped to non-negative real numbers (otherwise the log and cubic // is unmapped to non-negative real numbers (otherwise the log and cubic
// equations would respectively return -inf and -1/9.) // equations would respectively return -inf and -1/9.)

View file

@ -26,7 +26,7 @@ impl Mixer for SoftMixer {
fn volume(&self) -> u16 { fn volume(&self) -> u16 {
let mapped_volume = f64::from_bits(self.volume.load(Ordering::Relaxed)); let mapped_volume = f64::from_bits(self.volume.load(Ordering::Relaxed));
self.volume_ctrl.from_mapped(mapped_volume) self.volume_ctrl.to_unmapped(mapped_volume)
} }
fn set_volume(&self, volume: u16) { fn set_volume(&self, volume: u16) {

View file

@ -586,7 +586,7 @@ fn get_setup() -> Setup {
let stripped_env_key = |k: &str| { let stripped_env_key = |k: &str| {
k.trim_start_matches("LIBRESPOT_") k.trim_start_matches("LIBRESPOT_")
.replace("_", "-") .replace('_', "-")
.to_lowercase() .to_lowercase()
}; };