pub struct Scrobble { /* private fields */ }
Expand description
Repesents a single music track played at a point in time. In the Last.fm universe, this is known as a “scrobble”.
Takes an artist, track and album name. Can hold a timestamp indicating when the track was listened to.
Scrobble
objects are submitted via Scrobbler::now_playing
, Scrobbler::scrobble
and batches of
Scrobbles are sent via Scrobbler::scrobble_batch
.
Implementations§
Source§impl Scrobble
impl Scrobble
Sourcepub fn new(artist: &str, track: &str, album: &str) -> Self
pub fn new(artist: &str, track: &str, album: &str) -> Self
Constructs a new Scrobble instance, representing a single playthrough of a music track. Scrobble
s are
submitted to Last.fm via an instance of Scrobbler
. A new Scrobble
requires an artist name, song/track
name, and an album name.
§Example
let scrobble = Scrobble::new("Example Artist", "Example Track", "Example Album")
Sourcepub fn with_timestamp(&mut self, timestamp: u64) -> &mut Self
pub fn with_timestamp(&mut self, timestamp: u64) -> &mut Self
Sets the timestamp (date/time of play) of a Scrobble. Used in a builder-style pattern, typically after
Scrobble::new
.
§Example
let mut scrobble = Scrobble::new(...).with_timestamp(12345);
§Note on Timestamps
Scrobbles without timestamps are automatically assigned a timestamp of the current time when
submitted via Scrobbler::scrobble
or Scrobbler::scrobble_batch
. Timestamps only need to be
explicitly set when you are submitting a Scrobble at a point in the past, or in the future.
Sourcepub fn as_map(&self) -> HashMap<String, String>
pub fn as_map(&self) -> HashMap<String, String>
Converts the Scrobble metadata (track name, artist & album name) into a HashMap
. Map keys are
"track"
, "artist"
and "album"
. If a timestamp is set, it will be present in the map under key
"timestamp"
.
§Example
let scrobble = Scrobble::new("Example Artist", ...);
let scrobble_map = scrobble.as_map();
assert_eq!(scrobble_map.get("artist"), "Example Artist");
Trait Implementations§
Source§impl Extend<Scrobble> for ScrobbleBatch
impl Extend<Scrobble> for ScrobbleBatch
Source§fn extend<T: IntoIterator<Item = Scrobble>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Scrobble>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl From<&(&str, &str, &str)> for Scrobble
Converts from tuple of &str
s in the form (artist, track, album)
impl From<&(&str, &str, &str)> for Scrobble
Converts from tuple of &str
s in the form (artist, track, album)
Designed to make it easier to cooperate with other track info types.
Source§impl From<&(String, String, String)> for Scrobble
Converts from tuple of String
s in the form (artist, track, album)
impl From<&(String, String, String)> for Scrobble
Converts from tuple of String
s in the form (artist, track, album)
Designed to make it easier to cooperate with other track info types.