pub struct RecentTracksRequestBuilder { /* private fields */ }Expand description
Builder for recent tracks requests.
Implementations§
Source§impl RecentTracksRequestBuilder
impl RecentTracksRequestBuilder
Sourcepub const fn between(self, from: i64, to: i64) -> Self
pub const 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 fn on_progress(
self,
callback: impl Fn(u32, u32) + Send + Sync + 'static,
) -> Self
pub fn on_progress( self, callback: impl Fn(u32, u32) + Send + Sync + 'static, ) -> Self
Register a progress callback invoked with (fetched, total) after each batch.
Sourcepub async fn fetch(self) -> Result<TrackList<RecentTrack>>
pub async fn fetch(self) -> Result<TrackList<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 check_currently_playing(self) -> Result<Option<RecentTrack>>
pub async fn check_currently_playing(self) -> Result<Option<RecentTrack>>
Source§impl RecentTracksRequestBuilder
impl RecentTracksRequestBuilder
Sourcepub async fn fetch_extended(self) -> Result<TrackList<RecentTrackExtended>>
pub async fn fetch_extended(self) -> Result<TrackList<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_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 fetch_extended_and_update(self, file_path: &str) -> Result<usize>
pub async fn fetch_extended_and_update(self, file_path: &str) -> Result<usize>
Fetch only extended tracks newer than the most recent entry in an existing file and prepend them to it. If the file does not exist, all tracks are fetched and the file is created.
§Arguments
file_path- Path to the file to update (or create)
§Errors
Returns an error if the HTTP request fails, the response cannot be parsed, or the file cannot be read or written.
§Returns
Result<usize>- Number of new tracks prepended
Trait Implementations§
Source§impl Debug for RecentTracksRequestBuilder
impl Debug for RecentTracksRequestBuilder
Source§impl FetchAndSave for RecentTracksRequestBuilder
impl FetchAndSave for RecentTracksRequestBuilder
Source§type Item = RecentTrack
type Item = RecentTrack
The item type produced by this builder.
Source§fn resource_label() -> &'static str
fn resource_label() -> &'static str
A human-readable label used in log messages (e.g.
"top tracks").Source§fn latest_timestamp(items: &[Self::Item]) -> Option<u32>
fn latest_timestamp(items: &[Self::Item]) -> Option<u32>
Return the most recent timestamp from the given items, used to write a sidecar file
after saving. Return
None (the default) if the item type has no timestamp.Source§async fn fetch_and_save(
self,
format: FileFormat,
filename_prefix: &str,
) -> Result<String>
async fn fetch_and_save( self, format: FileFormat, filename_prefix: &str, ) -> Result<String>
Fetch items and save them to a file. Read more
Source§impl FetchAndUpdate for RecentTracksRequestBuilder
impl FetchAndUpdate for RecentTracksRequestBuilder
Auto Trait Implementations§
impl Freeze for RecentTracksRequestBuilder
impl !RefUnwindSafe for RecentTracksRequestBuilder
impl Send for RecentTracksRequestBuilder
impl Sync for RecentTracksRequestBuilder
impl Unpin for RecentTracksRequestBuilder
impl UnsafeUnpin for RecentTracksRequestBuilder
impl !UnwindSafe for RecentTracksRequestBuilder
Blanket Implementations§
Source§impl<T> Analyze for T
impl<T> Analyze for T
Source§type Item = <T as FetchAndSave>::Item
type Item = <T as FetchAndSave>::Item
The item type produced by this builder.
async fn do_fetch_for_analyze( self, ) -> Result<Vec<<T as Analyze>::Item>, LastFmError>
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