From 041f084d7f5f3e0731b712064f61105b509e5154 Mon Sep 17 00:00:00 2001 From: johannesd3 Date: Sun, 9 May 2021 12:59:34 +0200 Subject: [PATCH] Fix warnings --- connect/src/spirc.rs | 2 +- core/src/connection/handshake.rs | 2 +- core/src/connection/mod.rs | 4 ++-- core/src/mercury/mod.rs | 7 ++++--- core/src/spotify_id.rs | 2 ++ examples/playlist_tracks.rs | 1 - metadata/src/lib.rs | 3 ++- playback/src/player.rs | 4 ++-- 8 files changed, 14 insertions(+), 11 deletions(-) diff --git a/connect/src/spirc.rs b/connect/src/spirc.rs index 8f3b8101..eeb840d2 100644 --- a/connect/src/spirc.rs +++ b/connect/src/spirc.rs @@ -272,7 +272,7 @@ impl Spirc { .flatten_stream() .map(|response| -> Frame { let data = response.payload.first().unwrap(); - protobuf::parse_from_bytes(data).unwrap() + Frame::parse_from_bytes(data).unwrap() }), ); diff --git a/core/src/connection/handshake.rs b/core/src/connection/handshake.rs index a02832ae..82ec7672 100644 --- a/core/src/connection/handshake.rs +++ b/core/src/connection/handshake.rs @@ -102,7 +102,7 @@ where let header = read_into_accumulator(connection, 4, acc).await?; let size = BigEndian::read_u32(header) as usize; let data = read_into_accumulator(connection, size - 4, acc).await?; - let message = protobuf::parse_from_bytes(data).unwrap(); + let message = M::parse_from_bytes(data).unwrap(); Ok(message) } diff --git a/core/src/connection/mod.rs b/core/src/connection/mod.rs index d8a40129..58d3e83a 100644 --- a/core/src/connection/mod.rs +++ b/core/src/connection/mod.rs @@ -146,7 +146,7 @@ pub async fn authenticate( let (cmd, data) = transport.next().await.expect("EOF")?; match cmd { 0xac => { - let welcome_data: APWelcome = protobuf::parse_from_bytes(data.as_ref())?; + let welcome_data = APWelcome::parse_from_bytes(data.as_ref())?; let reusable_credentials = Credentials { username: welcome_data.get_canonical_username().to_owned(), @@ -157,7 +157,7 @@ pub async fn authenticate( Ok(reusable_credentials) } 0xad => { - let error_data: APLoginFailed = protobuf::parse_from_bytes(data.as_ref())?; + let error_data = APLoginFailed::parse_from_bytes(data.as_ref())?; Err(error_data.into()) } _ => { diff --git a/core/src/mercury/mod.rs b/core/src/mercury/mod.rs index 3ea15448..57650087 100644 --- a/core/src/mercury/mod.rs +++ b/core/src/mercury/mod.rs @@ -8,6 +8,7 @@ use std::task::Poll; use byteorder::{BigEndian, ByteOrder}; use bytes::Bytes; use futures_util::FutureExt; +use protobuf::Message; use tokio::sync::{mpsc, oneshot}; use crate::protocol; @@ -123,8 +124,8 @@ impl MercuryManager { if !response.payload.is_empty() { // Old subscription protocol, watch the provided list of URIs for sub in response.payload { - let mut sub: protocol::pubsub::Subscription = - protobuf::parse_from_bytes(&sub).unwrap(); + let mut sub = + protocol::pubsub::Subscription::parse_from_bytes(&sub).unwrap(); let sub_uri = sub.take_uri(); debug!("subscribed sub_uri={}", sub_uri); @@ -192,7 +193,7 @@ impl MercuryManager { fn complete_request(&self, cmd: u8, mut pending: MercuryPending) { let header_data = pending.parts.remove(0); - let header: protocol::mercury::Header = protobuf::parse_from_bytes(&header_data).unwrap(); + let header = protocol::mercury::Header::parse_from_bytes(&header_data).unwrap(); let response = MercuryResponse { uri: header.get_uri().to_string(), diff --git a/core/src/spotify_id.rs b/core/src/spotify_id.rs index 801c6ac9..3372572a 100644 --- a/core/src/spotify_id.rs +++ b/core/src/spotify_id.rs @@ -1,3 +1,5 @@ +#![allow(clippy::wrong_self_convention)] + use std::convert::TryInto; use std::fmt; diff --git a/examples/playlist_tracks.rs b/examples/playlist_tracks.rs index e96938cb..75c656bb 100644 --- a/examples/playlist_tracks.rs +++ b/examples/playlist_tracks.rs @@ -1,4 +1,3 @@ -use env_logger; use std::env; use librespot::core::authentication::Credentials; diff --git a/metadata/src/lib.rs b/metadata/src/lib.rs index 2c982ec7..d328a7d9 100644 --- a/metadata/src/lib.rs +++ b/metadata/src/lib.rs @@ -14,6 +14,7 @@ use librespot_core::mercury::MercuryError; use librespot_core::session::Session; use librespot_core::spotify_id::{FileId, SpotifyAudioType, SpotifyId}; use librespot_protocol as protocol; +use protobuf::Message; pub use crate::protocol::metadata::AudioFile_Format as FileFormat; @@ -123,7 +124,7 @@ pub trait Metadata: Send + Sized + 'static { let uri = Self::request_url(id); let response = session.mercury().get(uri).await?; let data = response.payload.first().expect("Empty payload"); - let msg: Self::Message = protobuf::parse_from_bytes(data).unwrap(); + let msg = Self::Message::parse_from_bytes(data).unwrap(); Ok(Self::parse(&msg, &session)) } diff --git a/playback/src/player.rs b/playback/src/player.rs index bdfd80be..f5f3ab66 100644 --- a/playback/src/player.rs +++ b/playback/src/player.rs @@ -538,10 +538,10 @@ impl PlayerState { play_request_id, loaded_track: PlayerLoadedTrackData { decoder, - duration_ms, - bytes_per_second, normalisation_factor, stream_loader_controller, + bytes_per_second, + duration_ms, stream_position_pcm, }, };