Skip to content

Commit

Permalink
Merge pull request #1284 from yubiuser/fix/clippy
Browse files Browse the repository at this point in the history
Fix/clippy
  • Loading branch information
roderickvd committed May 27, 2024
2 parents 7d45a94 + 2a8c4bd commit 8f9bec2
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion audio/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "librespot-audio"
version = "0.5.0-dev"
rust-version = "1.61"
rust-version = "1.71"
authors = ["Paul Lietar <paul@lietar.net>"]
description = "The audio fetching logic for librespot"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion connect/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "librespot-connect"
version = "0.5.0-dev"
rust-version = "1.61"
rust-version = "1.71"
authors = ["Paul Lietar <paul@lietar.net>"]
description = "The discovery and Spotify Connect logic for librespot"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "librespot-core"
version = "0.5.0-dev"
rust-version = "1.61"
rust-version = "1.71"
authors = ["Paul Lietar <paul@lietar.net>"]
build = "build.rs"
description = "The core functionality provided by librespot"
Expand Down
9 changes: 2 additions & 7 deletions core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -131,9 +132,3 @@ impl fmt::Display for DeviceType {
f.write_str(str)
}
}

impl Default for DeviceType {
fn default() -> DeviceType {
DeviceType::Speaker
}
}
10 changes: 5 additions & 5 deletions core/src/mercury/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ impl From<MercuryError> for Error {
}
}

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

Expand Down
14 changes: 7 additions & 7 deletions core/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -428,47 +428,47 @@ 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 {
self.0.data.read().client_name.clone()
}

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 {
self.0.data.read().client_brand_name.clone()
}

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 {
self.0.data.read().client_model_name.clone()
}

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 {
self.0.data.read().connection_id.clone()
}

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 {
self.0.data.read().user_data.canonical_username.clone()
}

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 {
Expand Down
6 changes: 3 additions & 3 deletions core/src/spclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion discovery/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "librespot-discovery"
version = "0.5.0-dev"
rust-version = "1.61"
rust-version = "1.71"
authors = ["Paul Lietar <paul@lietar.net>"]
description = "The discovery logic for librespot"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion metadata/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "librespot-metadata"
version = "0.5.0-dev"
rust-version = "1.61"
rust-version = "1.71"
authors = ["Paul Lietar <paul@lietar.net>"]
description = "The metadata logic for librespot"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion playback/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "librespot-playback"
version = "0.5.0-dev"
rust-version = "1.61"
rust-version = "1.71"
authors = ["Sasha Hilton <sashahilton00@gmail.com>"]
description = "The audio playback logic for librespot"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion protocol/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <paul@lietar.net>"]
build = "build.rs"
description = "The protobuf logic for communicating with Spotify servers"
Expand Down

0 comments on commit 8f9bec2

Please sign in to comment.