Files
empidee/src/commands/queue/playlistinfo.rs

43 lines
1.2 KiB
Rust

use crate::{
Request,
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
common::types::OneOrRange,
request_tokenizer::RequestTokenizer,
response_tokenizer::ResponseAttributes,
};
pub struct PlaylistInfo;
impl Command for PlaylistInfo {
type Request = Option<OneOrRange>;
type Response = ();
const COMMAND: &'static str = "playlistinfo";
fn serialize_request(&self, request: Self::Request) -> String {
match request {
Some(one_or_range) => format!("{} {}", Self::COMMAND, one_or_range),
None => Self::COMMAND.to_string(),
}
}
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
let one_or_range = parts
.next()
.map(|s| {
s.parse()
.map_err(|_| RequestParserError::SyntaxError(0, s.to_string()))
})
.transpose()?;
debug_assert!(parts.next().is_none());
Ok((Request::PlaylistInfo(one_or_range), ""))
}
fn parse_response(
_parts: ResponseAttributes<'_>,
) -> Result<Self::Response, ResponseParserError<'_>> {
unimplemented!()
}
}