pub struct Album<'a> { /* private fields */ }Expand description
Represents album-related operations in the Last.fm API.
Implementations§
Source§impl<'a> Album<'a>
impl<'a> Album<'a>
Creates a request to get tags for the album.
Examples found in repository?
examples/album_get_tags.rs (line 18)
6async fn main() -> Result<(), Box<dyn Error>> {
7 dotenv().ok();
8 let api_key = std::env::var("API_KEY").expect("API_KEY env variable is required");
9 let api_secret = std::env::var("API_SECRET").expect("API_SECRET env variable is required");
10
11 let lastfm = Lastfm::builder()
12 .api_key(api_key)
13 .api_secret(api_secret)
14 .build()?;
15
16 let response = lastfm
17 .album()
18 .get_tags()
19 .artist("Billie Eilish")
20 .album("HIT ME HARD AND SOFT")
21 .user("uppercase_")
22 .autocorrect(true)
23 .send()
24 .await?;
25
26 match response {
27 APIResponse::Success(value) => {
28 println!("{}", serde_json::json!(value));
29 }
30 APIResponse::Error(err) => {
31 println!("Error: {} - {}", err.error, err.message);
32 }
33 }
34
35 Ok(())
36}Creates a request to add tags to the album.
Examples found in repository?
examples/album_add_tags.rs (line 23)
6async fn main() -> Result<(), Box<dyn Error>> {
7 dotenv().ok();
8 let api_key = std::env::var("API_KEY").expect("API_KEY env variable is required");
9 let api_secret = std::env::var("API_SECRET").expect("API_SECRET env variable is required");
10 let sk = std::env::var("SK").expect("SK env variable is required");
11
12 let lastfm = Lastfm::builder()
13 .api_key(api_key)
14 .api_secret(api_secret)
15 .session_key(sk)
16 .build()?;
17
18 lastfm.auth();
19 // lastfm.set_sk(sk);
20
21 let response = lastfm
22 .album()
23 .add_tags()
24 .artist("Billie Eilish")
25 .album("HIT ME HARD AND SOFT")
26 .tags("aoty")
27 .send()
28 .await?;
29
30 match response {
31 APIResponse::Success(value) => {
32 println!("{}", value);
33 }
34 APIResponse::Error(err) => {
35 println!("Error: {} - {}", err.error, err.message);
36 }
37 }
38
39 Ok(())
40}Sourcepub fn get_info(&mut self) -> AlbumGetInfo<'_>
pub fn get_info(&mut self) -> AlbumGetInfo<'_>
Examples found in repository?
examples/album_get_info.rs (line 18)
6async fn main() -> Result<(), Box<dyn Error>> {
7 dotenv().ok();
8 let api_key = std::env::var("API_KEY").expect("API_KEY env variable is required");
9 let api_secret = std::env::var("API_SECRET").expect("API_SECRET env variable is required");
10
11 let lastfm = Lastfm::builder()
12 .api_key(api_key)
13 .api_secret(api_secret)
14 .build()?;
15
16 let response = lastfm
17 .album()
18 .get_info()
19 .artist("Billie Eilish")
20 .album("HIT ME HARD AND SOFT")
21 .username("uppercase_")
22 .autocorrect(true)
23 .send()
24 .await?;
25
26 match response {
27 APIResponse::Success(value) => {
28 println!("{:?}", value.album);
29 }
30 APIResponse::Error(err) => {
31 println!("Error: {} - {}", err.error, err.message);
32 }
33 }
34
35 Ok(())
36}Examples found in repository?
examples/album_get_top_tags.rs (line 18)
6async fn main() -> Result<(), Box<dyn Error>> {
7 dotenv().ok();
8 let api_key = std::env::var("API_KEY").expect("API_KEY env variable is required");
9 let api_secret = std::env::var("API_SECRET").expect("API_SECRET env variable is required");
10
11 let lastfm = Lastfm::builder()
12 .api_key(api_key)
13 .api_secret(api_secret)
14 .build()?;
15
16 let response = lastfm
17 .album()
18 .get_top_tags()
19 .artist("Billie Eilish")
20 .album("HIT ME HARD AND SOFT")
21 .autocorrect(true)
22 .send()
23 .await?;
24
25 match response {
26 APIResponse::Success(value) => {
27 println!("{:?}", value);
28 }
29 APIResponse::Error(err) => {
30 println!("Error: {} - {}", err.error, err.message);
31 }
32 }
33
34 Ok(())
35}Sourcepub fn remove_tag(&mut self) -> AlbumRemoveTag<'_>
pub fn remove_tag(&mut self) -> AlbumRemoveTag<'_>
Examples found in repository?
examples/album_remove_tags.rs (line 23)
6async fn main() -> Result<(), Box<dyn Error>> {
7 dotenv().ok();
8 let api_key = std::env::var("API_KEY").expect("API_KEY env variable is required");
9 let api_secret = std::env::var("API_SECRET").expect("API_SECRET env variable is required");
10 let sk = std::env::var("SK").expect("SK env variable is required");
11
12 let lastfm = Lastfm::builder()
13 .api_key(api_key)
14 .api_secret(api_secret)
15 .session_key(sk)
16 .build()?;
17
18 let _sk = lastfm.auth();
19 // lastfm.set_sk(sk);
20
21 let response = lastfm
22 .album()
23 .remove_tag()
24 .artist("Billie Eilish")
25 .album("HIT ME HARD AND SOFT")
26 .tag("aoty")
27 .send()
28 .await?;
29
30 match response {
31 APIResponse::Success(value) => {
32 println!("{}", value);
33 }
34 APIResponse::Error(err) => {
35 println!("Error: {} - {}", err.error, err.message);
36 }
37 }
38
39 Ok(())
40}Sourcepub fn search(&mut self) -> AlbumSearch<'_>
pub fn search(&mut self) -> AlbumSearch<'_>
Examples found in repository?
examples/album_search.rs (line 18)
6async fn main() -> Result<(), Box<dyn Error>> {
7 dotenv().ok();
8 let api_key = std::env::var("API_KEY").expect("API_KEY env variable is required");
9 let api_secret = std::env::var("API_SECRET").expect("API_SECRET env variable is required");
10
11 let lastfm = Lastfm::builder()
12 .api_key(api_key)
13 .api_secret(api_secret)
14 .build()?;
15
16 let response = lastfm
17 .album()
18 .search()
19 .album("HIT ME HARD AND SOFT")
20 .limit(30)
21 .page(1)
22 .send()
23 .await?;
24
25 match response {
26 APIResponse::Success(value) => {
27 println!("{}", value);
28 }
29 APIResponse::Error(err) => {
30 println!("Error: {} - {}", err.error, err.message);
31 }
32 }
33
34 Ok(())
35}Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Album<'a>
impl<'a> !RefUnwindSafe for Album<'a>
impl<'a> Send for Album<'a>
impl<'a> Sync for Album<'a>
impl<'a> Unpin for Album<'a>
impl<'a> !UnwindSafe for Album<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more