use std::fmt;
use serde::Deserialize;
use zbus::zvariant::{Type, Value};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Type)]
#[zvariant(signature = "s")]
#[doc(alias = "Playlist_Ordering")]
pub enum PlaylistOrdering {
#[serde(rename = "Alphabetical")]
Alphabetical,
#[serde(rename = "Created")]
CreationDate,
#[serde(rename = "Modified")]
ModifiedDate,
#[serde(rename = "Played")]
LastPlayDate,
#[serde(rename = "User")]
UserDefined,
}
impl PlaylistOrdering {
pub fn as_str(&self) -> &'static str {
match self {
Self::Alphabetical => "Alphabetical",
Self::CreationDate => "Created",
Self::ModifiedDate => "Modified",
Self::LastPlayDate => "Played",
Self::UserDefined => "User",
}
}
}
impl fmt::Display for PlaylistOrdering {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
impl<'a> From<PlaylistOrdering> for Value<'a> {
fn from(status: PlaylistOrdering) -> Self {
Value::new(status.as_str())
}
}