lastfm_edit/track.rs
1/// Represents a music track with associated metadata.
2///
3/// This structure contains track information as parsed from Last.fm pages,
4/// including play count and optional timestamp data for scrobbles.
5///
6/// # Examples
7///
8/// ```rust
9/// use lastfm_edit::Track;
10///
11/// let track = Track {
12/// name: "Paranoid Android".to_string(),
13/// artist: "Radiohead".to_string(),
14/// playcount: 42,
15/// timestamp: Some(1640995200), // Unix timestamp
16/// };
17///
18/// println!("{} by {} (played {} times)", track.name, track.artist, track.playcount);
19/// ```
20#[derive(Debug, Clone)]
21pub struct Track {
22 /// The track name/title
23 pub name: String,
24 /// The artist name
25 pub artist: String,
26 /// Number of times this track has been played/scrobbled
27 pub playcount: u32,
28 /// Unix timestamp of when this track was scrobbled (if available)
29 ///
30 /// This field is populated when tracks are retrieved from recent scrobbles
31 /// or individual scrobble data, but may be `None` for aggregate track listings.
32 pub timestamp: Option<u64>,
33}
34
35/// Represents a paginated collection of tracks.
36///
37/// This structure is returned by track listing methods and provides
38/// information about the current page and pagination state.
39///
40/// # Examples
41///
42/// ```rust
43/// use lastfm_edit::{Track, TrackPage};
44///
45/// let page = TrackPage {
46/// tracks: vec![
47/// Track {
48/// name: "Song 1".to_string(),
49/// artist: "Artist".to_string(),
50/// playcount: 10,
51/// timestamp: None,
52/// }
53/// ],
54/// page_number: 1,
55/// has_next_page: true,
56/// total_pages: Some(5),
57/// };
58///
59/// println!("Page {} of {:?}, {} tracks",
60/// page.page_number,
61/// page.total_pages,
62/// page.tracks.len());
63/// ```
64#[derive(Debug, Clone)]
65pub struct TrackPage {
66 /// The tracks on this page
67 pub tracks: Vec<Track>,
68 /// Current page number (1-indexed)
69 pub page_number: u32,
70 /// Whether there are more pages available
71 pub has_next_page: bool,
72 /// Total number of pages, if known
73 ///
74 /// This may be `None` if the total page count cannot be determined
75 /// from the Last.fm response.
76 pub total_pages: Option<u32>,
77}