mpris_server/
playback_status.rs

1use std::fmt;
2
3use zbus::zvariant::{Type, Value};
4
5/// A playback state.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Type)]
7#[zvariant(signature = "s")]
8#[doc(alias = "Playback_Status")]
9pub enum PlaybackStatus {
10    /// A track is currently playing.
11    Playing,
12    /// A track is currently paused.
13    Paused,
14    /// There is no track currently playing.
15    Stopped,
16}
17
18impl PlaybackStatus {
19    /// Returns the string representation of this playback status.
20    pub fn as_str(&self) -> &'static str {
21        match self {
22            Self::Playing => "Playing",
23            Self::Paused => "Paused",
24            Self::Stopped => "Stopped",
25        }
26    }
27}
28
29impl fmt::Display for PlaybackStatus {
30    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31        f.write_str(self.as_str())
32    }
33}
34
35impl From<PlaybackStatus> for Value<'_> {
36    fn from(status: PlaybackStatus) -> Self {
37        Value::new(status.as_str())
38    }
39}