fix clippy warnings

This commit is contained in:
Guillaume Desmottes 2023-01-02 19:01:35 +01:00
parent f72048e5e1
commit 7f2cb684c9
8 changed files with 10 additions and 16 deletions

View file

@ -1138,7 +1138,7 @@ impl SpircTask {
self.state.set_status(PlayStatus::kPlayStatusPlay);
self.update_state_position(position_ms);
self.play_status = SpircPlayStatus::Playing {
nominal_start_time: self.now_ms() as i64 - position_ms as i64,
nominal_start_time: self.now_ms() - position_ms as i64,
preloading_of_next_track_triggered,
};
}

View file

@ -173,5 +173,5 @@ where
D: serde::Deserializer<'de>,
{
let v: String = serde::Deserialize::deserialize(de)?;
base64::decode(&v).map_err(|e| serde::de::Error::custom(e.to_string()))
base64::decode(v).map_err(|e| serde::de::Error::custom(e.to_string()))
}

View file

@ -61,7 +61,7 @@ impl RequestHandler {
}
fn handle_get_info(&self) -> Response<hyper::Body> {
let public_key = base64::encode(&self.keys.public_key());
let public_key = base64::encode(self.keys.public_key());
let device_type: &str = self.config.device_type.into();
let mut active_user = String::new();
if let Some(username) = &self.username {
@ -139,7 +139,7 @@ impl RequestHandler {
let encrypted = &encrypted_blob[16..encrypted_blob_len - 20];
let cksum = &encrypted_blob[encrypted_blob_len - 20..encrypted_blob_len];
let base_key = Sha1::digest(&shared_key);
let base_key = Sha1::digest(shared_key);
let base_key = &base_key[..16];
let checksum_key = {
@ -179,7 +179,7 @@ impl RequestHandler {
data
};
let credentials = Credentials::with_blob(username, &decrypted, &self.config.device_id)?;
let credentials = Credentials::with_blob(username, decrypted, &self.config.device_id)?;
self.tx.send(credentials)?;

View file

@ -109,7 +109,7 @@ impl AudioItem {
)
};
let popularity = track.popularity.max(0).min(100) as u8;
let popularity = track.popularity.clamp(0, 100) as u8;
let number = track.number.max(0) as u32;
let disc_number = track.disc_number.max(0) as u32;

View file

@ -76,13 +76,7 @@ impl Converter {
let min = -factor;
let max = factor - 1.0;
if int_value < min {
min
} else if int_value > max {
max
} else {
int_value
}
int_value.clamp(min, max)
}
pub fn f64_to_f32(&mut self, samples: &[f64]) -> Vec<f32> {

View file

@ -15,6 +15,6 @@ pub mod player;
pub const SAMPLE_RATE: u32 = 44100;
pub const NUM_CHANNELS: u8 = 2;
pub const SAMPLES_PER_SECOND: u32 = SAMPLE_RATE as u32 * NUM_CHANNELS as u32;
pub const SAMPLES_PER_SECOND: u32 = SAMPLE_RATE * NUM_CHANNELS as u32;
pub const PAGES_PER_MS: f64 = SAMPLE_RATE as f64 / 1000.0;
pub const MS_PER_PAGE: f64 = 1000.0 / SAMPLE_RATE as f64;

View file

@ -1311,7 +1311,7 @@ impl Future for PlayerInternal {
self.send_event(PlayerEvent::PositionCorrection {
play_request_id,
track_id,
position_ms: new_stream_position_ms as u32,
position_ms: new_stream_position_ms,
});
}
}

View file

@ -9,7 +9,7 @@ fn out_dir() -> PathBuf {
}
fn cleanup() {
let _ = fs::remove_dir_all(&out_dir());
let _ = fs::remove_dir_all(out_dir());
}
fn compile() {