Lines
0 %
Functions
use crate::commands::{
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
ResponseParserError,
};
pub struct PlaylistDelete;
impl Command for PlaylistDelete {
type Response = ();
const COMMAND: &'static str = "playlistdelete";
fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
let playlist_name = parts
.next()
.ok_or(RequestParserError::UnexpectedEOF)?
.to_string();
// TODO: this can be a range, according to docs
let position = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
let position = position
.parse()
.map_err(|_| RequestParserError::SyntaxError(0, position.to_string()))?;
debug_assert!(parts.next().is_none());
Ok((Request::PlaylistDelete(playlist_name, position), ""))
}
fn parse_response(
parts: ResponseAttributes<'_>,
) -> Result<Self::Response, ResponseParserError> {
debug_assert!(parts.is_empty());
Ok(())