use crate::{Artwork, ArtworkKind, Item, MediaId, PlaybackState, QuotaOf};
#[uniffi::export]
impl Item {
#[uniffi::method(name = "item_id")]
pub fn id_owned(&self) -> MediaId {
self.id().clone()
}
#[uniffi::method(name = "item_title")]
pub fn title_owned(&self) -> String {
self.title().to_owned()
}
#[uniffi::method(name = "item_artwork")]
pub fn artwork_owned(&self) -> Vec<Artwork> {
self.artwork().to_vec()
}
#[uniffi::method(name = "item_duration")]
pub fn duration_owned(&self) -> Option<std::time::Duration> {
self.duration()
}
pub fn poster(&self) -> Option<Artwork> {
self.artwork_of(ArtworkKind::Poster).cloned()
}
pub fn background(&self) -> Option<Artwork> {
self.artwork_of(ArtworkKind::Background).cloned()
}
pub fn thumb(&self) -> Option<Artwork> {
self.artwork_of(ArtworkKind::Thumb).cloned()
}
#[uniffi::method(name = "item_playback")]
pub fn playback_owned(&self) -> Option<PlaybackState> {
self.playback().cloned()
}
}
#[uniffi::export]
pub fn media_origin(id: MediaId) -> Option<String> {
id.origin().map(str::to_owned)
}
#[uniffi::export]
impl QuotaOf {
pub fn is_user(&self) -> bool {
*self == QuotaOf::User
}
}