Lines
0 %
Functions
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::{
commands::{CommandResponse, ResponseParserError, empty_command_request},
response_tokenizer::{
ResponseAttributes, get_and_parse_optional_property, get_and_parse_property,
},
types::{DbSongInfo, Priority, SongId, SongPosition},
};
// Displays the song info of the current song (same song that is identified in status)
empty_command_request!(CurrentSong, "currentsong");
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CurrentSongResponse {
position: SongPosition,
id: SongId,
priority: Option<Priority>,
song_info: DbSongInfo,
}
impl CurrentSongResponse {
pub fn new(
) -> Self {
Self {
position,
id,
priority,
song_info,
impl CommandResponse for CurrentSongResponse {
type Request = CurrentSongRequest;
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
let mut parts: HashMap<_, _> = parts.into_map()?;
let position: SongPosition = get_and_parse_property!(parts, "Pos", Text);
let id: SongId = get_and_parse_property!(parts, "Id", Text);
let priority: Option<Priority> = get_and_parse_optional_property!(parts, "Prio", Text);
parts.remove("Pos");
parts.remove("Id");
parts.remove("Prio");
let song_info = DbSongInfo::parse_map(parts)?;
Ok(CurrentSongResponse {
})
fn serialize(&self) -> Vec<u8> {
unimplemented!("response serialization is not yet implemented for CurrentSongResponse")