1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use std::convert::Into;
use std::borrow::Cow;
use url::Url as StdUrl;
use lastfm_type::{LastfmType, Request, RequestParams};
use super::common::{Url, Image, str_to_val};
#[derive(Debug)]
pub enum Params<'pr> {
GetArtists {
user: &'pr str,
limit: Option<u32>,
page: Option<u32>,
},
}
impl<'pr> RequestParams for Params<'pr> {
fn method(&self) -> &str {
match *self {
Params::GetArtists { .. } => "library.getartists"
}
}
fn needs_signature(&self) -> bool {
false
}
fn needs_session_key(&self) -> bool {
false
}
fn append_to(&self, url: &mut StdUrl) {
let mut query = url.query_pairs_mut();
match *self {
Params::GetArtists { user, limit, page } => {
params!(query, [user: user], [limit: cv!(limit), page: cv!(page)]);
}
}
}
}
#[derive(Deserialize, Debug)]
pub struct Artist<'dt> {
pub name: Cow<'dt, str>,
pub mbid: Option<&'dt str>,
url: Url<'dt>,
#[serde(deserialize_with = "str_to_val")]
pub playcount: u32,
#[serde(deserialize_with = "str_to_val")]
pub tagcount: u32,
#[serde(deserialize_with = "str_to_val")]
pub streamable: u32,
pub image: Vec<Image<'dt>>,
}
#[derive(Deserialize, Debug)]
pub struct GetArtists<'dt> {
#[serde(borrow)]
pub artist: Option<Vec<Artist<'dt>>>,
}
lastfm_t!(
artists,
GetArtists,
_Artists,
Params,
GetArtists,
[user: &'rq str, limit: Option<u32>, page: Option<u32>]
);