Merge pull request #1284 from yubiuser/fix/clippy

Fix/clippy
This commit is contained in:
Roderick van Domburg 2024-05-27 22:33:10 +02:00 committed by GitHub
commit 8f9bec21d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 28 additions and 30 deletions

View file

@ -5,6 +5,9 @@ FROM rust:${rust_version}-${debian_version}
ARG DEBIAN_FRONTEND=noninteractive ARG DEBIAN_FRONTEND=noninteractive
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL="sparse" ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL="sparse"
ENV RUST_BACKTRACE=1
ENV RUSTFLAGS=-Dwarnings
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y --no-install-recommends \ apt-get install -y --no-install-recommends \

View file

@ -1,7 +1,7 @@
[package] [package]
name = "librespot" name = "librespot"
version = "0.5.0-dev" version = "0.5.0-dev"
rust-version = "1.61" rust-version = "1.71"
authors = ["Librespot Org"] authors = ["Librespot Org"]
license = "MIT" license = "MIT"
description = "An open source client library for Spotify, with support for Spotify Connect" description = "An open source client library for Spotify, with support for Spotify Connect"

View file

@ -1,7 +1,7 @@
[package] [package]
name = "librespot-audio" name = "librespot-audio"
version = "0.5.0-dev" version = "0.5.0-dev"
rust-version = "1.61" rust-version = "1.71"
authors = ["Paul Lietar <paul@lietar.net>"] authors = ["Paul Lietar <paul@lietar.net>"]
description = "The audio fetching logic for librespot" description = "The audio fetching logic for librespot"
license = "MIT" license = "MIT"

View file

@ -1,7 +1,7 @@
[package] [package]
name = "librespot-connect" name = "librespot-connect"
version = "0.5.0-dev" version = "0.5.0-dev"
rust-version = "1.61" rust-version = "1.71"
authors = ["Paul Lietar <paul@lietar.net>"] authors = ["Paul Lietar <paul@lietar.net>"]
description = "The discovery and Spotify Connect logic for librespot" description = "The discovery and Spotify Connect logic for librespot"
license = "MIT" license = "MIT"

View file

@ -1,7 +1,7 @@
[package] [package]
name = "librespot-core" name = "librespot-core"
version = "0.5.0-dev" version = "0.5.0-dev"
rust-version = "1.61" rust-version = "1.71"
authors = ["Paul Lietar <paul@lietar.net>"] authors = ["Paul Lietar <paul@lietar.net>"]
build = "build.rs" build = "build.rs"
description = "The core functionality provided by librespot" description = "The core functionality provided by librespot"

View file

@ -43,12 +43,13 @@ impl Default for SessionConfig {
} }
} }
#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, PartialEq, Eq, Default)]
pub enum DeviceType { pub enum DeviceType {
Unknown = 0, Unknown = 0,
Computer = 1, Computer = 1,
Tablet = 2, Tablet = 2,
Smartphone = 3, Smartphone = 3,
#[default]
Speaker = 4, Speaker = 4,
Tv = 5, Tv = 5,
Avr = 6, Avr = 6,
@ -131,9 +132,3 @@ impl fmt::Display for DeviceType {
f.write_str(str) f.write_str(str)
} }
} }
impl Default for DeviceType {
fn default() -> DeviceType {
DeviceType::Speaker
}
}

View file

@ -49,15 +49,15 @@ impl From<MercuryError> for Error {
} }
} }
impl ToString for MercuryMethod { impl std::fmt::Display for MercuryMethod {
fn to_string(&self) -> String { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self { let s = match *self {
MercuryMethod::Get => "GET", MercuryMethod::Get => "GET",
MercuryMethod::Sub => "SUB", MercuryMethod::Sub => "SUB",
MercuryMethod::Unsub => "UNSUB", MercuryMethod::Unsub => "UNSUB",
MercuryMethod::Send => "SEND", MercuryMethod::Send => "SEND",
} };
.to_owned() write!(f, "{}", s)
} }
} }

View file

@ -358,7 +358,7 @@ impl Session {
loop { loop {
match reader.read_event_into(&mut buf) { match reader.read_event_into(&mut buf) {
Ok(Event::Start(ref element)) => { Ok(Event::Start(ref element)) => {
current_element = std::str::from_utf8(element)?.to_owned() std::str::from_utf8(element)?.clone_into(&mut current_element)
} }
Ok(Event::End(_)) => { Ok(Event::End(_)) => {
current_element = String::new(); current_element = String::new();
@ -428,7 +428,7 @@ impl Session {
} }
pub fn set_client_id(&self, client_id: &str) { pub fn set_client_id(&self, client_id: &str) {
self.0.data.write().client_id = client_id.to_owned(); client_id.clone_into(&mut self.0.data.write().client_id);
} }
pub fn client_name(&self) -> String { pub fn client_name(&self) -> String {
@ -436,7 +436,7 @@ impl Session {
} }
pub fn set_client_name(&self, client_name: &str) { pub fn set_client_name(&self, client_name: &str) {
self.0.data.write().client_name = client_name.to_owned(); client_name.clone_into(&mut self.0.data.write().client_name);
} }
pub fn client_brand_name(&self) -> String { pub fn client_brand_name(&self) -> String {
@ -444,7 +444,7 @@ impl Session {
} }
pub fn set_client_brand_name(&self, client_brand_name: &str) { pub fn set_client_brand_name(&self, client_brand_name: &str) {
self.0.data.write().client_brand_name = client_brand_name.to_owned(); client_brand_name.clone_into(&mut self.0.data.write().client_brand_name);
} }
pub fn client_model_name(&self) -> String { pub fn client_model_name(&self) -> String {
@ -452,7 +452,7 @@ impl Session {
} }
pub fn set_client_model_name(&self, client_model_name: &str) { pub fn set_client_model_name(&self, client_model_name: &str) {
self.0.data.write().client_model_name = client_model_name.to_owned(); client_model_name.clone_into(&mut self.0.data.write().client_model_name);
} }
pub fn connection_id(&self) -> String { pub fn connection_id(&self) -> String {
@ -460,7 +460,7 @@ impl Session {
} }
pub fn set_connection_id(&self, connection_id: &str) { pub fn set_connection_id(&self, connection_id: &str) {
self.0.data.write().connection_id = connection_id.to_owned(); connection_id.clone_into(&mut self.0.data.write().connection_id);
} }
pub fn username(&self) -> String { pub fn username(&self) -> String {
@ -468,7 +468,7 @@ impl Session {
} }
pub fn set_username(&self, username: &str) { pub fn set_username(&self, username: &str) {
self.0.data.write().user_data.canonical_username = username.to_owned(); username.clone_into(&mut self.0.data.write().user_data.canonical_username);
} }
pub fn country(&self) -> String { pub fn country(&self) -> String {

View file

@ -239,9 +239,9 @@ impl SpClient {
let android_data = platform_data.mut_android(); let android_data = platform_data.mut_android();
android_data.android_version = os_version; android_data.android_version = os_version;
android_data.api_version = 31; android_data.api_version = 31;
android_data.device_name = "Pixel".to_owned(); "Pixel".clone_into(&mut android_data.device_name);
android_data.model_str = "GF5KQ".to_owned(); "GF5KQ".clone_into(&mut android_data.model_str);
android_data.vendor = "Google".to_owned(); "Google".clone_into(&mut android_data.vendor);
} }
"macos" => { "macos" => {
let macos_data = platform_data.mut_desktop_macos(); let macos_data = platform_data.mut_desktop_macos();

View file

@ -1,7 +1,7 @@
[package] [package]
name = "librespot-discovery" name = "librespot-discovery"
version = "0.5.0-dev" version = "0.5.0-dev"
rust-version = "1.61" rust-version = "1.71"
authors = ["Paul Lietar <paul@lietar.net>"] authors = ["Paul Lietar <paul@lietar.net>"]
description = "The discovery logic for librespot" description = "The discovery logic for librespot"
license = "MIT" license = "MIT"

View file

@ -1,7 +1,7 @@
[package] [package]
name = "librespot-metadata" name = "librespot-metadata"
version = "0.5.0-dev" version = "0.5.0-dev"
rust-version = "1.61" rust-version = "1.71"
authors = ["Paul Lietar <paul@lietar.net>"] authors = ["Paul Lietar <paul@lietar.net>"]
description = "The metadata logic for librespot" description = "The metadata logic for librespot"
license = "MIT" license = "MIT"

View file

@ -1,7 +1,7 @@
[package] [package]
name = "librespot-playback" name = "librespot-playback"
version = "0.5.0-dev" version = "0.5.0-dev"
rust-version = "1.61" rust-version = "1.71"
authors = ["Sasha Hilton <sashahilton00@gmail.com>"] authors = ["Sasha Hilton <sashahilton00@gmail.com>"]
description = "The audio playback logic for librespot" description = "The audio playback logic for librespot"
license = "MIT" license = "MIT"

View file

@ -1,7 +1,7 @@
[package] [package]
name = "librespot-protocol" name = "librespot-protocol"
version = "0.5.0-dev" version = "0.5.0-dev"
rust-version = "1.61" rust-version = "1.71"
authors = ["Paul Liétar <paul@lietar.net>"] authors = ["Paul Liétar <paul@lietar.net>"]
build = "build.rs" build = "build.rs"
description = "The protobuf logic for communicating with Spotify servers" description = "The protobuf logic for communicating with Spotify servers"