pub struct TopTracksRequestBuilder { /* private fields */ }Expand description
Builder for top tracks requests
Implementations§
Source§impl TopTracksRequestBuilder
impl TopTracksRequestBuilder
Sourcepub fn limit(self, limit: u32) -> Self
pub fn limit(self, limit: u32) -> Self
Set the maximum number of tracks to fetch
§Arguments
limit- Maximum number of tracks to fetch. The Last.fm API supports fetching up to thousands of tracks. If you need all tracks, useunlimited()instead.
Sourcepub fn period(self, period: Period) -> Self
pub fn period(self, period: Period) -> Self
Set the time period for top tracks
§Arguments
period- The time range to calculate top tracks over. UsePeriod::Overallfor all-time,Period::Weekfor last 7 days,Period::Monthfor last 30 days, etc. If not set, defaults to the Last.fm API’s default behavior (typically overall).
§Example
ⓘ
use lastfm_client::api::Period;
let tracks = client.top_tracks("username")
.period(Period::Month)
.limit(50)
.fetch()
.await?;Sourcepub async fn fetch(self) -> Result<Vec<TopTrack>>
pub async fn fetch(self) -> Result<Vec<TopTrack>>
Fetch the tracks
§Errors
Returns an error if the HTTP request fails or the response cannot be parsed.
Sourcepub async fn fetch_and_save(
self,
format: FileFormat,
filename_prefix: &str,
) -> Result<String>
pub async fn fetch_and_save( self, format: FileFormat, filename_prefix: &str, ) -> Result<String>
Fetch tracks and save them to a file
§Arguments
format- The file format to save the tracks infilename_prefix- Prefix for the generated filename
§Errors
Returns an error if the HTTP request fails, response cannot be parsed, or file cannot be saved.
§Returns
Result<String>- The filename of the saved file
Auto Trait Implementations§
impl Freeze for TopTracksRequestBuilder
impl !RefUnwindSafe for TopTracksRequestBuilder
impl Send for TopTracksRequestBuilder
impl Sync for TopTracksRequestBuilder
impl Unpin for TopTracksRequestBuilder
impl !UnwindSafe for TopTracksRequestBuilder
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