use std::str::FromStr; use serde::{Deserialize, Serialize}; use crate::common::{Audio, BoolOrOneshot, SongId, SongPosition}; use crate::commands::{ get_and_parse_optional_property, get_and_parse_property, get_optional_property, get_property, Command, GenericResponseValue, Request, RequestParserResult, ResponseParserError, }; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum StatusResponseState { Play, Stop, Pause, } impl FromStr for StatusResponseState { type Err = (); fn from_str(s: &str) -> Result { match s { "play" => Ok(StatusResponseState::Play), "stop" => Ok(StatusResponseState::Stop), "pause" => Ok(StatusResponseState::Pause), _ => Err(()), } } } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct StatusResponse { pub partition: String, // Note: the Option<>::None here is serialized as -1 pub volume: Option, pub repeat: bool, pub random: bool, pub single: BoolOrOneshot, pub consume: BoolOrOneshot, pub playlist: u32, pub playlist_length: u64, pub state: StatusResponseState, pub song: Option, pub song_id: Option, pub next_song: Option, pub next_song_id: Option, pub time: Option<(u64, u64)>, pub elapsed: Option, pub duration: Option, pub bitrate: Option, pub xfade: Option, pub mixrampdb: Option, pub mixrampdelay: Option, pub audio: Option