pub struct Metadata { /* private fields */ }
Expand description
A structured representation of the Player
metadata.
Implementations§
source§impl Metadata
impl Metadata
sourcepub fn new<S>(track_id: S) -> Selfwhere
S: Into<String>,
pub fn new<S>(track_id: S) -> Selfwhere S: Into<String>,
Create a new Metadata
struct with a given track_id
.
This is mostly useful for test fixtures and other places where you want to work with mock data.
sourcepub fn get(&self, key: &str) -> Option<&Value>
pub fn get(&self, key: &str) -> Option<&Value>
Get a value from the metadata by key name.
Examples
if let Some(MetadataValue::String(name)) = metadata.get("xesam:composer") {
println!("Composed by: {}", name);
}
sourcepub fn album_artists(&self) -> Option<Vec<&str>>
pub fn album_artists(&self) -> Option<Vec<&str>>
A list of artists of the album the track appears on.
Based on xesam:albumArtist
The album artist(s).
sourcepub fn album_name(&self) -> Option<&str>
pub fn album_name(&self) -> Option<&str>
The name of the album the track appears on.
Based on xesam:album
The album name.
sourcepub fn art_url(&self) -> Option<&str>
pub fn art_url(&self) -> Option<&str>
An URL to album art of the current track.
Based on mpris:artUrl
The location of an image representing the track or album. Clients should not assume this will continue to exist when the media player stops giving out the URL.
sourcepub fn artists(&self) -> Option<Vec<&str>>
pub fn artists(&self) -> Option<Vec<&str>>
A list of artists of the track.
Based on xesam:artist
The track artist(s).
sourcepub fn auto_rating(&self) -> Option<f64>
pub fn auto_rating(&self) -> Option<f64>
Based on xesam:autoRating
An automatically-generated rating, based on things such as how often it has been played. This should be in the range 0.0 to 1.0.
sourcepub fn disc_number(&self) -> Option<i32>
pub fn disc_number(&self) -> Option<i32>
Based on xesam:discNumber
The disc number on the album that this track is from.
sourcepub fn length_in_microseconds(&self) -> Option<u64>
pub fn length_in_microseconds(&self) -> Option<u64>
The duration of the track, in microseconds
Based on mpris:length
The duration of the track in microseconds.
sourcepub fn length(&self) -> Option<Duration>
pub fn length(&self) -> Option<Duration>
The duration of the track, as a Duration
Based on mpris:length
.
sourcepub fn title(&self) -> Option<&str>
pub fn title(&self) -> Option<&str>
The name of the track.
Based on xesam:title
The track title.
sourcepub fn track_number(&self) -> Option<i32>
pub fn track_number(&self) -> Option<i32>
The track number on the disc of the album the track appears on.
Based on xesam:trackNumber
The track number on the album disc.
sourcepub fn url(&self) -> Option<&str>
pub fn url(&self) -> Option<&str>
A URL to the media being played.
Based on xesam:url
The location of the media file.
sourcepub fn as_hashmap(&self) -> HashMap<&str, &Value>
pub fn as_hashmap(&self) -> HashMap<&str, &Value>
Returns an owned HashMap
of borrowed values from this Metadata
. Useful if you need a
mutable hash but don’t have ownership of Metadata
or want to consume it.
If you want to convert to a HashMap
, use Into::into
instead.