pub struct RecentTracksIterator<'a> { /* private fields */ }Expand description
Iterator for browsing a user’s recent tracks/scrobbles.
This iterator provides access to the user’s recent listening history with timestamps, which is essential for finding tracks that can be edited. It supports optional timestamp-based filtering to avoid reprocessing old data.
§Examples
let mut client = LastFmEditClient::new(Box::new(http_client::native::NativeClient::new()));
// client.login(...).await?;
// Get recent tracks with timestamps
let mut recent = client.recent_tracks();
while let Some(track) = recent.next().await? {
if let Some(timestamp) = track.timestamp {
println!("{} - {} ({})", track.artist, track.name, timestamp);
}
}
// Or stop at a specific timestamp to avoid reprocessing
let last_processed = 1640995200;
let mut recent = client.recent_tracks().with_stop_timestamp(last_processed);
let new_tracks = recent.collect_all().await?;Implementations§
Source§impl<'a> RecentTracksIterator<'a>
impl<'a> RecentTracksIterator<'a>
Sourcepub fn new(client: &'a mut LastFmEditClient) -> Self
pub fn new(client: &'a mut LastFmEditClient) -> Self
Create a new recent tracks iterator.
This is typically called via LastFmEditClient::recent_tracks.
Sourcepub fn with_stop_timestamp(self, timestamp: u64) -> Self
pub fn with_stop_timestamp(self, timestamp: u64) -> Self
Set a timestamp to stop iteration at.
When this is set, the iterator will stop returning tracks once it encounters a track with a timestamp less than or equal to the specified value. This is useful for incremental processing to avoid reprocessing old data.
§Arguments
timestamp- Unix timestamp to stop at
§Examples
let mut client = LastFmEditClient::new(Box::new(http_client::native::NativeClient::new()));
let last_processed = 1640995200; // Some previous timestamp
let mut recent = client.recent_tracks().with_stop_timestamp(last_processed);
let new_tracks = recent.collect_all().await?; // Only gets new tracksTrait Implementations§
Source§impl<'a> AsyncPaginatedIterator for RecentTracksIterator<'a>
impl<'a> AsyncPaginatedIterator for RecentTracksIterator<'a>
Source§async fn next(&mut self) -> Result<Option<Self::Item>>
async fn next(&mut self) -> Result<Option<Self::Item>>
Fetch the next item from the iterator. Read more
Source§fn current_page(&self) -> u32
fn current_page(&self) -> u32
Get the current page number (0-indexed). Read more
Auto Trait Implementations§
impl<'a> Freeze for RecentTracksIterator<'a>
impl<'a> !RefUnwindSafe for RecentTracksIterator<'a>
impl<'a> Send for RecentTracksIterator<'a>
impl<'a> Sync for RecentTracksIterator<'a>
impl<'a> Unpin for RecentTracksIterator<'a>
impl<'a> !UnwindSafe for RecentTracksIterator<'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