pub struct RecentTracksRequestBuilder { /* private fields */ }Expand description
Builder for recent tracks requests
Implementations§
Source§impl RecentTracksRequestBuilder
impl RecentTracksRequestBuilder
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 between(self, from: i64, to: i64) -> Self
pub fn between(self, from: i64, to: i64) -> Self
Fetch tracks between two timestamps
§Arguments
from- Start Unix timestamp in seconds (not milliseconds) since January 1, 1970 UTCto- End Unix timestamp in seconds (not milliseconds) since January 1, 1970 UTC
§Example
ⓘ
// Fetch tracks between January 1, 2024 and February 1, 2024 (UTC)
let tracks = client.recent_tracks()
.builder("username")
.between(1704067200, 1706745600)
.fetch()
.await?;Sourcepub async fn fetch(self) -> Result<Vec<RecentTrack>>
pub async fn fetch(self) -> Result<Vec<RecentTrack>>
Fetch the tracks
§Errors
Returns an error if:
- The HTTP request fails or the response cannot be parsed
- The date range is invalid (to <= from when both timestamps are set)
Sourcepub async fn fetch_extended(self) -> Result<Vec<RecentTrackExtended>>
pub async fn fetch_extended(self) -> Result<Vec<RecentTrackExtended>>
Fetch tracks with extended information
§Errors
Returns an error if:
- The HTTP request fails or the response cannot be parsed
- The date range is invalid (to <= from when both timestamps are set)
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
Sourcepub async fn fetch_extended_and_save(
self,
format: FileFormat,
filename_prefix: &str,
) -> Result<String>
pub async fn fetch_extended_and_save( self, format: FileFormat, filename_prefix: &str, ) -> Result<String>
Fetch tracks with extended information 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
Sourcepub async fn analyze(self, threshold: usize) -> Result<TrackStats>
pub async fn analyze(self, threshold: usize) -> Result<TrackStats>
Analyze tracks and return statistics
§Arguments
threshold- Minimum play count threshold. Tracks with fewer plays than this value will be counted separately intracks_below_threshold. For example, use 5 to identify tracks played less than 5 times.
§Errors
Returns an error if the HTTP request fails or the response cannot be parsed.
§Returns
Result<crate::analytics::TrackStats>- Analysis results including play counts, most played tracks, etc.
Sourcepub async fn analyze_and_print(self, threshold: usize) -> Result<()>
pub async fn analyze_and_print(self, threshold: usize) -> Result<()>
Analyze tracks and print statistics
§Arguments
threshold- Minimum play count threshold. Tracks with fewer plays than this value will be counted separately. For example, use 5 to identify tracks played less than 5 times.
§Errors
Returns an error if the HTTP request fails or the response cannot be parsed.
Sourcepub async fn check_currently_playing(self) -> Result<Option<RecentTrack>>
pub async fn check_currently_playing(self) -> Result<Option<RecentTrack>>
Auto Trait Implementations§
impl Freeze for RecentTracksRequestBuilder
impl !RefUnwindSafe for RecentTracksRequestBuilder
impl Send for RecentTracksRequestBuilder
impl Sync for RecentTracksRequestBuilder
impl Unpin for RecentTracksRequestBuilder
impl !UnwindSafe for RecentTracksRequestBuilder
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