pub struct TrackID(_);
Expand description
Represents the MPRIS Track_Id
type.
use mpris::TrackID;
let no_track = TrackID::new("/org/mpris/MediaPlayer2/TrackList/NoTrack").unwrap();
TrackIDs must be valid D-Bus object paths according to the spec.
Errors
Trying to construct a TrackID
from a string that is not a valid D-Bus Path will fail.
let result = TrackID::new("invalid track ID");
assert!(result.is_err());
Implementations§
source§impl TrackID
impl TrackID
sourcepub fn new<S: Into<String>>(id: S) -> Result<Self, String>
pub fn new<S: Into<String>>(id: S) -> Result<Self, String>
Create a new TrackID
from a string-like entity.
This is not something you should normally do as the IDs are temporary and will only work if the Player knows about it.
However, creating TrackID
s manually can help with test setup, comparisons, etc.
Example
use mpris::TrackID;
let id = TrackID::new("/dbus/path/id").expect("Parse error");
sourcepub fn no_track() -> Self
pub fn no_track() -> Self
Return a new TrackID
that matches the MPRIS standard for the “No track” sentinel value.
Some APIs takes this in order to signal a missing value for a track, for example by saying that no specific track is playing, or that a track should be added at the start of the list instead of after a specific track.
The actual path is “/org/mpris/MediaPlayer2/TrackList/NoTrack”.
This value is only valid in some cases. Make sure to read the MPRIS specification before you use this manually.