Struct mpris::Metadata

source ·
pub struct Metadata { /* private fields */ }
Expand description

Implementations§

source§

impl Metadata

source

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.

source

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);
}
source

pub fn track_id(&self) -> Option<TrackID>

The track ID.

If the TrackID could not be parsed as a proper TrackID, None will be returned.

Based on mpris:trackid

A unique identity for this track within the context of an MPRIS object.

source

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).

source

pub fn album_name(&self) -> Option<&str>

The name of the album the track appears on.

Based on xesam:album

The album name.

source

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.

source

pub fn artists(&self) -> Option<Vec<&str>>

A list of artists of the track.

Based on xesam:artist

The track artist(s).

source

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.

source

pub fn disc_number(&self) -> Option<i32>

Based on xesam:discNumber

The disc number on the album that this track is from.

source

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.

source

pub fn length(&self) -> Option<Duration>

The duration of the track, as a Duration

Based on mpris:length.

source

pub fn title(&self) -> Option<&str>

The name of the track.

Based on xesam:title

The track title.

source

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.

source

pub fn url(&self) -> Option<&str>

A URL to the media being played.

Based on xesam:url

The location of the media file.

source

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.

source

pub fn iter(&self) -> impl Iterator<Item = (&str, &Value)>

Iterate all metadata keys and values.

source

pub fn keys(&self) -> impl Iterator<Item = &str>

Iterate all metadata keys.

source

pub fn is_empty(&self) -> bool

Returns true if there is no metadata

Trait Implementations§

source§

impl Clone for Metadata

source§

fn clone(&self) -> Metadata

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Metadata

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Metadata

source§

fn default() -> Metadata

Returns the “default value” for a type. Read more
source§

impl From<HashMap<String, Value, RandomState>> for Metadata

source§

fn from(values: HashMap<String, Value>) -> Self

Converts to this type from the input type.
source§

impl From<Metadata> for HashMap<String, Value>

source§

fn from(metadata: Metadata) -> Self

Converts to this type from the input type.
source§

impl IntoIterator for Metadata

§

type Item = (String, Value)

The type of the elements being iterated over.
§

type IntoIter = IntoIter<String, Value>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.