Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ assets = [
]

[workspace.lints]
clippy.implicit_clone = "warn"
clippy.redundant_closure_for_method_calls = "warn"

[lints]
Expand Down
4 changes: 2 additions & 2 deletions connect/src/state/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,14 @@ impl ConnectState {
// - queue resorting is done by each client and orients itself by the given uid
// - if no uid is present, resorting doesn't work or behaves not as intended
let uid = match ctx_track.uid.as_ref() {
Some(uid) if !uid.is_empty() => uid.to_string(),
Some(uid) if !uid.is_empty() => uid.clone(),
// so providing a unique id should allow to resort the queue
_ => Uuid::new_v4().as_simple().to_string(),
};

let mut metadata = page_metadata.cloned().unwrap_or_default();
for (k, v) in &ctx_track.metadata {
metadata.insert(k.to_string(), v.to_string());
metadata.insert(k.clone(), v.clone());
}

let mut track = ProvidedTrack {
Expand Down
2 changes: 1 addition & 1 deletion core/src/login5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl Login5Manager {
}

let method = Login_method::StoredCredential(StoredCredential {
username: self.session().username().to_string(),
username: self.session().username(),
data: auth_data,
..Default::default()
});
Expand Down
4 changes: 2 additions & 2 deletions core/src/spclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ impl SpClient {
challenge_answer.ChallengeType =
ChallengeType::CHALLENGE_HASH_CASH.into();

challenge_answers.state = state.to_string();
challenge_answers.state = state.clone();
challenge_answers.answers.push(challenge_answer);

trace!("Answering hash cash challenge");
Expand Down Expand Up @@ -347,7 +347,7 @@ impl SpClient {
};

let granted_token = token_response.granted_token();
let access_token = granted_token.token.to_owned();
let access_token = granted_token.token.clone();

self.lock(|inner| {
let client_token = Token {
Expand Down
2 changes: 1 addition & 1 deletion core/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl TokenProvider {
);
let request = self.session().mercury().get(query_uri)?;
let response = request.await?;
let data = response.payload.first().ok_or(TokenError::Empty)?.to_vec();
let data = response.payload.first().ok_or(TokenError::Empty)?.clone();
let token = Token::from_json(String::from_utf8(data)?)?;
trace!("Got token: {token:#?}");
self.lock(|inner| inner.tokens.push(token.clone()));
Expand Down
2 changes: 1 addition & 1 deletion discovery/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl RequestHandler {

let encrypted_blob_len = encrypted_blob.len();
if encrypted_blob_len < 16 {
return Err(DiscoveryError::HmacError(encrypted_blob.to_vec()).into());
return Err(DiscoveryError::HmacError(encrypted_blob).into());
}

let iv = &encrypted_blob[0..16];
Expand Down
2 changes: 1 addition & 1 deletion metadata/src/album.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl TryFrom<&<Self as Metadata>::Message> for Album {
covers: album.cover_group.get_or_default().into(),
external_ids: album.external_id.as_slice().into(),
discs: album.disc.as_slice().try_into()?,
reviews: album.review.to_vec(),
reviews: album.review.clone(),
copyrights: album.copyright.as_slice().into(),
restrictions: album.restriction.as_slice().into(),
related: album.related.as_slice().try_into()?,
Expand Down
2 changes: 1 addition & 1 deletion metadata/src/availability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl TryFrom<&AvailabilityMessage> for Availability {
type Error = librespot_core::Error;
fn try_from(availability: &AvailabilityMessage) -> Result<Self, Self::Error> {
Ok(Self {
catalogue_strs: availability.catalogue_str.to_vec(),
catalogue_strs: availability.catalogue_str.clone(),
start: availability.start.get_or_default().try_into()?,
})
}
Expand Down
2 changes: 1 addition & 1 deletion metadata/src/content_rating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl From<&ContentRatingMessage> for ContentRating {
fn from(content_rating: &ContentRatingMessage) -> Self {
Self {
country: content_rating.country().to_owned(),
tags: content_rating.tag.to_vec(),
tags: content_rating.tag.clone(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion metadata/src/episode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl TryFrom<&<Self as Metadata>::Message> for Episode {
audio_previews: episode.audio_preview.as_slice().into(),
restrictions: episode.restriction.as_slice().into(),
freeze_frames: episode.freeze_frame.image.as_slice().into(),
keywords: episode.keyword.to_vec(),
keywords: episode.keyword.clone(),
allow_background_playback: episode.allow_background_playback(),
availability: episode.availability.as_slice().try_into()?,
external_url: episode.external_url().to_owned(),
Expand Down
2 changes: 1 addition & 1 deletion metadata/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub trait MercuryRequest {
let response = request.await?;
match response.payload.first() {
Some(data) => {
let data = data.to_vec().into();
let data = data.clone().into();
trace!("Received metadata: {data:?}");
Ok(data)
}
Expand Down
2 changes: 1 addition & 1 deletion metadata/src/restriction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl From<&RestrictionMessage> for Restriction {
.type_
.unwrap_or_default()
.enum_value_or_default(),
catalogue_strs: restriction.catalogue_str.to_vec(),
catalogue_strs: restriction.catalogue_str.clone(),
countries_allowed,
countries_forbidden,
}
Expand Down
2 changes: 1 addition & 1 deletion metadata/src/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl TryFrom<&<Self as Metadata>::Message> for Show {
episodes: show.episode.as_slice().try_into()?,
copyrights: show.copyright.as_slice().into(),
restrictions: show.restriction.as_slice().into(),
keywords: show.keyword.to_vec(),
keywords: show.keyword.clone(),
media_type: show.media_type(),
consumption_order: show.consumption_order(),
availability: show.availability.as_slice().try_into()?,
Expand Down
4 changes: 2 additions & 2 deletions metadata/src/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ impl TryFrom<&<Self as Metadata>::Message> for Track {
alternatives: track.alternative.as_slice().try_into()?,
sale_periods: track.sale_period.as_slice().try_into()?,
previews: track.preview.as_slice().into(),
tags: track.tags.to_vec(),
tags: track.tags.clone(),
earliest_live_timestamp: Date::from_timestamp_ms(track.earliest_live_timestamp())?,
has_lyrics: track.has_lyrics(),
availability: track.availability.as_slice().try_into()?,
licensor: Uuid::from_slice(track.licensor.uuid()).unwrap_or_else(|_| Uuid::nil()),
language_of_performance: track.language_of_performance.to_vec(),
language_of_performance: track.language_of_performance.clone(),
content_ratings: track.content_rating.as_slice().into(),
original_title: track.original_title().to_owned(),
version_title: track.version_title().to_owned(),
Expand Down
12 changes: 6 additions & 6 deletions oauth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ impl OAuthClient {
_ => self.scopes.clone(),
};
let refresh_token = match resp.refresh_token() {
Some(t) => t.secret().to_string(),
Some(t) => t.secret().clone(),
_ => "".to_string(), // Spotify always provides a refresh token.
};
Ok(OAuthToken {
access_token: resp.access_token().secret().to_string(),
access_token: resp.access_token().secret().clone(),
refresh_token,
expires_at: Instant::now()
+ resp
Expand Down Expand Up @@ -410,7 +410,7 @@ impl OAuthClientBuilder {
}
})?;

let client = BasicClient::new(ClientId::new(self.client_id.to_string()))
let client = BasicClient::new(ClientId::new(self.client_id.clone()))
.set_auth_uri(auth_url)
.set_token_uri(token_url)
.set_redirect_uri(redirect_url);
Expand Down Expand Up @@ -496,17 +496,17 @@ pub fn get_access_token(
_ => scopes.into_iter().map(Into::into).collect(),
};
let refresh_token = match token.refresh_token() {
Some(t) => t.secret().to_string(),
Some(t) => t.secret().clone(),
_ => "".to_string(), // Spotify always provides a refresh token.
};
Ok(OAuthToken {
access_token: token.access_token().secret().to_string(),
access_token: token.access_token().secret().clone(),
refresh_token,
expires_at: Instant::now()
+ token
.expires_in()
.unwrap_or_else(|| Duration::from_secs(3600)),
token_type: format!("{:?}", token.token_type()).to_string(), // Urgh!?
token_type: format!("{:?}", token.token_type()),
scopes: token_scopes,
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ async fn get_setup() -> Setup {
env_vars
.iter()
.find(|(k, _)| stripped_env_key(k) == opt)
.map(|(_, v)| v.to_string())
.map(|(_, v)| v.clone())
}
};

Expand Down