Trait sunk::Media

source ·
pub trait Media {
    fn has_cover_art(&self) -> bool;
    fn cover_id(&self) -> Option<&str>;
    fn cover_art<U: Into<Option<usize>>>(
        &self,
        client: &Client,
        size: U
    ) -> Result<Vec<u8>>; fn cover_art_url<U: Into<Option<usize>>>(
        &self,
        client: &Client,
        size: U
    ) -> Result<String>; }
Expand description

A trait deriving common methods for any form of media.

Required Methods

Returns whether or not the media has an associated cover.

Returns the cover ID associated with the media, if any.

The ID may be a number, an identifier-number pair, or simply empty. This is due to the introduction of ID3 tags into the Subsonic API; collections of media (such as albums or playlists) will typically have an identifier-number ID, while raw media (such as songs or videos) will have a numeric or no identifier.

Because the method has the potential to return either a string-y or numeric ID, the number is coerced into a &str to avoid type checking workarounds.

Returns the raw bytes of the cover art of the media.

The image is guaranteed to be valid and displayable by the Subsonic server (as long as the method does not error), but makes no guarantees on the encoding of the image.

Errors

Aside from errors that the Client may cause, the method will error if the media does not have an associated cover art.

Returns the URL pointing to the cover art of the media.

Errors

Aside from errors that the Client may cause, the method will error if the media does not have an associated cover art.

Implementors