Skip to content

Commit

Permalink
chore(lint): run cargo fmt & clippy
Browse files Browse the repository at this point in the history
Signed-off-by: rajput-hemant <rajput.hemant2001@gmail.com>
  • Loading branch information
rajput-hemant committed Sep 19, 2023
1 parent 421b381 commit eb06f6c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 50 deletions.
2 changes: 1 addition & 1 deletion api/artist/songs_albums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async fn main() -> Result<(), Error> {
pub async fn handler(req: Request) -> Result<Response<Body>, Error> {
let parsed_url = Url::parse(&req.uri().to_string()).unwrap();

let path = parsed_url.path().split("/").last().unwrap().to_string();
let path = parsed_url.path().split('/').last().unwrap().to_string();

let hash_query: HashMap<String, String> = parsed_url.query_pairs().into_owned().collect();

Expand Down
2 changes: 1 addition & 1 deletion src/handlers/search_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
},
};

#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Params {
query: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion src/models/get.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::{
album::{AlbumRequest, AlbumResponse},
misc::Quality,
misc::Union3,
playlist::{PlaylistRequest, PlaylistResponse},
misc::Quality,
song::{SongRequest, SongResponse},
};
use serde::{Deserialize, Serialize};
Expand Down
30 changes: 13 additions & 17 deletions src/payloads/radio_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use crate::models::radio::{
use super::song_payload;

/// Create radio station payload from radio station request
///
///
/// ## Arguments
///
///
/// * `station` - Radio station request
///
///
/// ## Returns
///
///
/// * `RadioStationResponse` - Radio station payload
pub fn radio_station_payload(station: RadioStationRequest) -> RadioStationResponse {
RadioStationResponse {
Expand All @@ -20,13 +20,13 @@ pub fn radio_station_payload(station: RadioStationRequest) -> RadioStationRespon
}

/// Create radio songs payload from radio songs request
///
///
/// ## Arguments
///
///
/// * `radio` - Radio songs request
///
///
/// ## Returns
///
///
/// * `RadioSongResponse` - Radio songs payload
pub fn radio_songs_payload(radio: RadioSongRequest) -> RadioSongResponse {
let station_id = radio.stationid;
Expand All @@ -37,17 +37,13 @@ pub fn radio_songs_payload(radio: RadioSongRequest) -> RadioSongResponse {
return RadioSongResponse { station_id, songs };
}

match radio.data {
Some(song) => {
for (k, v) in song {
if k == "stationid" || k == "error" {
continue;
}
songs.push(song_payload(v.song));
if let Some(song) = radio.data {
for (k, v) in song {
if k == "stationid" || k == "error" {
continue;
}
songs.push(song_payload(v.song));
}

None => {}
}

RadioSongResponse { station_id, songs }
Expand Down
2 changes: 1 addition & 1 deletion src/payloads/search_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ fn search_album_payload(album: SearchAlbumRequest) -> SearchAlbumResponse {
fn search_artist_payload(artist: SearchArtistRequest) -> SearchArtistResponse {
SearchArtistResponse {
id: artist.id,
name: if artist.title == None {
name: if artist.title.is_none() {
artist.name
} else {
artist.title
Expand Down
2 changes: 1 addition & 1 deletion src/services/api_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub async fn http<T: DeserializeOwned>(

let body: T = api_service
.client
.get(url.clone())
.get(url)
.headers(headers)
.send()
.await?
Expand Down
29 changes: 1 addition & 28 deletions src/services/radio_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use super::api_service::http;
/// ## Returns
///
/// * `Result<RRadioStation, String>` - Result of radio station creation
#[allow(clippy::too_many_arguments)]
pub async fn create_radio(
song_id: String,
artist_id: String,
Expand Down Expand Up @@ -153,31 +154,3 @@ pub async fn get_radio_songs(
}
}
}

// #[cfg(test)]
// mod tests {
// use super::*;

// #[tokio::test]
// async fn test_create_radio() -> Result<(), Error> {
// let result = create_radio(vec!["Arijit Singh"], "hindi", RadioStationType::Artist).await?;

// dbg!(result);

// Ok(())
// }

// #[tokio::test]
// async fn test_get_radio_songs() -> Result<(), Error> {
// let result = get_radio_songs(
// "z4jVxXCk2U70olZbGArPKmAINUg2-4NRNs1JimLO9Cgb5pKgepaRvA__~^~artist_radio~^~459320",
// 10,
// 0,
// )
// .await?;

// dbg!(result);

// Ok(())
// }
// }

0 comments on commit eb06f6c

Please sign in to comment.