Album

Struct Album 

Source
pub struct Album<'a> { /* private fields */ }
Expand description

Represents album-related operations in the Last.fm API.

Implementations§

Source§

impl<'a> Album<'a>

Source

pub fn get_tags(&mut self) -> AlbumGetTags<'_>

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}
Source

pub fn add_tags(&mut self) -> AlbumAddTagsRequest<'_>

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}
Source

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}
Source

pub fn get_top_tags(&mut self) -> AlbumGetTopTags<'_>

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}
Source

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}
Source

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§

Source§

impl<'a> Debug for Album<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,