[][src]Struct mpris::TrackList

pub struct TrackList { /* fields omitted */ }

Represents a MediaPlayer2.TrackList.

This type offers an iterator of the track's metadata, when provided a Player instance that matches the list.

TrackLists cache metadata about tracks so multiple iterations should be fast. It also enables signals received from the Player to pre-populate metadata and to keep everything up to date.

See MediaPlayer2.TrackList interface

Methods

impl TrackList[src]

pub fn new(ids: Vec<TrackID>) -> TrackList[src]

Construct a new TrackList without any existing cache.

pub fn ids(&self) -> &[TrackID][src]

Get a list of TrackIDs that are part of this TrackList. The order matters.

pub fn len(&self) -> usize[src]

Returns the number of tracks on the list.

pub fn is_empty(&self) -> bool[src]

If the tracklist is empty or not.

pub fn get(&self, index: usize) -> Option<&TrackID>[src]

Return the TrackID of the index. Out-of-bounds will result in None.

pub fn insert(&mut self, after: &TrackID, metadata: Metadata)[src]

Insert a new track (via its metadata) after another one. If the provided ID cannot be found on the list, it will be inserted at the end.

NOTE: This is not something that will affect a player's actual tracklist; this is strictly for client-side representation. Use this if you want to maintain your own instance of TrackList or to feed your code with test fixtures.

pub fn remove(&mut self, id: &TrackID)[src]

Removes a track from the list and metadata cache.

Note: If the same id is present multiple times, all of them will be removed.

pub fn clear(&mut self)[src]

Clears the entire list and cache.

pub fn replace(&mut self, other: TrackList)[src]

Replace the contents with the contents of the provided list. Cache will be reused when possible.

pub fn add_metadata(&mut self, metadata: Metadata)[src]

Adds/updates the metadata cache for a track (as identified by Metadata::track_id).

The metadata will be added to the cache even if the TrackID isn't part of the list, but will be cleaned out again after the next cache cleanup unless the track in question have been added to the list before then.

If provided metadata does not contain a TrackID, the metadata will be discarded.

pub fn replace_track_metadata(
    &mut self,
    old_id: &TrackID,
    new_metadata: Metadata
) -> Option<TrackID>
[src]

Replaces a track on the list with a new entry. The new metadata could contain a new track ID, and will in that case replace the old ID on the tracklist.

The new ID (which might be identical to the old ID) will be returned by this method.

If the old ID cannot be found, the metadata will be discarded and None will be returned.

If provided metadata does not contain a TrackID, the metadata will be discarded and None will be returned.

pub fn metadata_iter(
    &self,
    player: &Player
) -> Result<MetadataIter, TrackListError>
[src]

Iterates the tracks in the tracklist, returning a tuple of TrackID and Metadata for that track.

Metadata will be loaded from the provided player when not present in the metadata cache. If metadata loading fails, then a DBusError will be returned instead of the iterator.

pub fn reload(&mut self, player: &Player) -> Result<(), TrackListError>[src]

Reloads the tracklist from the given player. This can be compared with loading a new track list, but in this case the metadata cache can be maintained for tracks that remain on the list.

Cache for tracks that are no longer part of the player's tracklist will be removed.

pub fn reload_cache(&self, player: &Player) -> Result<(), TrackListError>[src]

Clears all cache and reloads metadata for all tracks.

Cache will be replaced after the new metadata has been loaded, so on load errors the cache will still be maintained.

pub fn complete_cache(&self, player: &Player) -> Result<(), TrackListError>[src]

Fill in any holes in the cache so that each track on the list has a cached Metadata entry.

If all tracks already have a cache entry, then this will do nothing.

Trait Implementations

impl Debug for TrackList[src]

impl Default for TrackList[src]

impl<'a> From<Vec<Path<'a>>> for TrackList[src]

impl From<Vec<TrackID>> for TrackList[src]

impl FromIterator<TrackID> for TrackList[src]

impl PartialEq<TrackList> for TrackList[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.