From 5fc8d2d3e6d15ad958f9024171930a2710b0e37a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Sat, 11 May 2024 12:29:25 +0000 Subject: [PATCH 1/6] Add rust env variables to devcontainer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- .devcontainer/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 31a4f0def..20e041cf3 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -5,6 +5,9 @@ FROM rust:${rust_version}-${debian_version} ARG DEBIAN_FRONTEND=noninteractive ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL="sparse" +ENV RUST_BACKTRACE=1 +ENV RUSTFLAGS=-Dwarnings + RUN apt-get update && \ apt-get install -y --no-install-recommends \ From 0884a0d76a24d2928a829c4971f309f2223b3a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Sat, 11 May 2024 18:53:46 +0000 Subject: [PATCH 2/6] Fix assigning_clones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- core/src/session.rs | 14 +++++++------- core/src/spclient.rs | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/src/session.rs b/core/src/session.rs index 7801d68b8..b8c55d205 100755 --- a/core/src/session.rs +++ b/core/src/session.rs @@ -358,7 +358,7 @@ impl Session { loop { match reader.read_event_into(&mut buf) { 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(_)) => { current_element = String::new(); @@ -428,7 +428,7 @@ impl Session { } 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 { @@ -436,7 +436,7 @@ impl Session { } 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 { @@ -444,7 +444,7 @@ impl Session { } 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 { @@ -452,7 +452,7 @@ impl Session { } 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 { @@ -460,7 +460,7 @@ impl Session { } 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 { @@ -468,7 +468,7 @@ impl Session { } 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 { diff --git a/core/src/spclient.rs b/core/src/spclient.rs index e5550d888..072cf40c4 100644 --- a/core/src/spclient.rs +++ b/core/src/spclient.rs @@ -239,9 +239,9 @@ impl SpClient { let android_data = platform_data.mut_android(); android_data.android_version = os_version; android_data.api_version = 31; - android_data.device_name = "Pixel".to_owned(); - android_data.model_str = "GF5KQ".to_owned(); - android_data.vendor = "Google".to_owned(); + "Pixel".clone_into(&mut android_data.device_name); + "GF5KQ".clone_into(&mut android_data.model_str); + "Google".clone_into(&mut android_data.vendor); } "macos" => { let macos_data = platform_data.mut_desktop_macos(); From ca035c9d17a7fc9958abe8a951203ca0054063c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Sat, 11 May 2024 19:03:06 +0000 Subject: [PATCH 3/6] Set MSRV in Cargo.toml files to 1.71 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- Cargo.toml | 2 +- audio/Cargo.toml | 2 +- connect/Cargo.toml | 2 +- core/Cargo.toml | 2 +- discovery/Cargo.toml | 2 +- metadata/Cargo.toml | 2 +- playback/Cargo.toml | 2 +- protocol/Cargo.toml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0782b67fc..9b4ae8717 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "librespot" version = "0.5.0-dev" -rust-version = "1.61" +rust-version = "1.71" authors = ["Librespot Org"] license = "MIT" description = "An open source client library for Spotify, with support for Spotify Connect" diff --git a/audio/Cargo.toml b/audio/Cargo.toml index eaa84313e..94b900c70 100644 --- a/audio/Cargo.toml +++ b/audio/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "librespot-audio" version = "0.5.0-dev" -rust-version = "1.61" +rust-version = "1.71" authors = ["Paul Lietar "] description = "The audio fetching logic for librespot" license = "MIT" diff --git a/connect/Cargo.toml b/connect/Cargo.toml index 1e02df84d..419a54d64 100644 --- a/connect/Cargo.toml +++ b/connect/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "librespot-connect" version = "0.5.0-dev" -rust-version = "1.61" +rust-version = "1.71" authors = ["Paul Lietar "] description = "The discovery and Spotify Connect logic for librespot" license = "MIT" diff --git a/core/Cargo.toml b/core/Cargo.toml index 99bdd0ed4..2f515480b 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "librespot-core" version = "0.5.0-dev" -rust-version = "1.61" +rust-version = "1.71" authors = ["Paul Lietar "] build = "build.rs" description = "The core functionality provided by librespot" diff --git a/discovery/Cargo.toml b/discovery/Cargo.toml index 22de44026..f4414ebd8 100644 --- a/discovery/Cargo.toml +++ b/discovery/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "librespot-discovery" version = "0.5.0-dev" -rust-version = "1.61" +rust-version = "1.71" authors = ["Paul Lietar "] description = "The discovery logic for librespot" license = "MIT" diff --git a/metadata/Cargo.toml b/metadata/Cargo.toml index 9da0ce424..a35a943fc 100644 --- a/metadata/Cargo.toml +++ b/metadata/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "librespot-metadata" version = "0.5.0-dev" -rust-version = "1.61" +rust-version = "1.71" authors = ["Paul Lietar "] description = "The metadata logic for librespot" license = "MIT" diff --git a/playback/Cargo.toml b/playback/Cargo.toml index dfb537c8c..8d2d36d37 100644 --- a/playback/Cargo.toml +++ b/playback/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "librespot-playback" version = "0.5.0-dev" -rust-version = "1.61" +rust-version = "1.71" authors = ["Sasha Hilton "] description = "The audio playback logic for librespot" license = "MIT" diff --git a/protocol/Cargo.toml b/protocol/Cargo.toml index b86a82253..f0ce2d7c0 100644 --- a/protocol/Cargo.toml +++ b/protocol/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "librespot-protocol" version = "0.5.0-dev" -rust-version = "1.61" +rust-version = "1.71" authors = ["Paul Liétar "] build = "build.rs" description = "The protobuf logic for communicating with Spotify servers" From 99878e0f72184b1f1d0e65f1f32922a30e489da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Sat, 11 May 2024 19:13:08 +0000 Subject: [PATCH 4/6] Fix derivable_impls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- core/src/config.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/core/src/config.rs b/core/src/config.rs index bd7136f1c..674c5020f 100644 --- a/core/src/config.rs +++ b/core/src/config.rs @@ -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 { Unknown = 0, Computer = 1, Tablet = 2, Smartphone = 3, + #[default] Speaker = 4, Tv = 5, Avr = 6, @@ -131,9 +132,3 @@ impl fmt::Display for DeviceType { f.write_str(str) } } - -impl Default for DeviceType { - fn default() -> DeviceType { - DeviceType::Speaker - } -} From 27d3c9e92fd060e6d316b46b9a4c8cdad6f809d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Sat, 11 May 2024 19:53:55 +0000 Subject: [PATCH 5/6] Fix clippy::to_string_trait_impl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- core/src/mercury/types.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/core/src/mercury/types.rs b/core/src/mercury/types.rs index 9c7593feb..43b9c5cd0 100644 --- a/core/src/mercury/types.rs +++ b/core/src/mercury/types.rs @@ -49,15 +49,14 @@ impl From for Error { } } -impl ToString for MercuryMethod { - fn to_string(&self) -> String { +impl std::fmt::Display for MercuryMethod { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match *self { - MercuryMethod::Get => "GET", - MercuryMethod::Sub => "SUB", - MercuryMethod::Unsub => "UNSUB", - MercuryMethod::Send => "SEND", + MercuryMethod::Get => write!(f, "GET"), + MercuryMethod::Sub => write!(f, "SUB"), + MercuryMethod::Unsub => write!(f, "UNSUB"), + MercuryMethod::Send => write!(f, "SEND"), } - .to_owned() } } From 2a8c4bdc011d05c26df90387416b6a4bcb49cee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 27 May 2024 20:10:00 +0000 Subject: [PATCH 6/6] Apply reviewer's suggestion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- core/src/mercury/types.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/src/mercury/types.rs b/core/src/mercury/types.rs index 43b9c5cd0..70fb3f862 100644 --- a/core/src/mercury/types.rs +++ b/core/src/mercury/types.rs @@ -51,12 +51,13 @@ impl From for Error { impl std::fmt::Display for MercuryMethod { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match *self { - MercuryMethod::Get => write!(f, "GET"), - MercuryMethod::Sub => write!(f, "SUB"), - MercuryMethod::Unsub => write!(f, "UNSUB"), - MercuryMethod::Send => write!(f, "SEND"), - } + let s = match *self { + MercuryMethod::Get => "GET", + MercuryMethod::Sub => "SUB", + MercuryMethod::Unsub => "UNSUB", + MercuryMethod::Send => "SEND", + }; + write!(f, "{}", s) } }