pub struct RecentTracksIterator { /* 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 = LastFmEditClientImpl::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 RecentTracksIterator
impl RecentTracksIterator
Sourcepub fn new(client: LastFmEditClientImpl) -> Self
pub fn new(client: LastFmEditClientImpl) -> Self
Create a new recent tracks iterator starting from page 1.
This is typically called via LastFmEditClient::recent_tracks.
Sourcepub fn with_starting_page(
client: LastFmEditClientImpl,
starting_page: u32,
) -> Self
pub fn with_starting_page( client: LastFmEditClientImpl, starting_page: u32, ) -> Self
Create a new recent tracks iterator starting from a specific page.
This allows resuming pagination from an arbitrary page, useful for continuing from where a previous iteration left off.
§Arguments
client- The LastFmEditClient to use for API callsstarting_page- The page number to start from (1-indexed)
§Examples
let mut client = LastFmEditClientImpl::new(Box::new(http_client::native::NativeClient::new()));
// Start from page 5
let mut recent = client.recent_tracks_from_page(5);
let tracks = recent.take(10).await?;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 = LastFmEditClientImpl::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 tracks