Lines
0 %
Functions
use crate::commands::{
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
ResponseParserError,
};
pub struct PlaylistMove;
impl Command for PlaylistMove {
type Response = ();
const COMMAND: &'static str = "playlistmove";
fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
let playlist_name = parts
.next()
.ok_or(RequestParserError::UnexpectedEOF)?
.to_string();
let mut from = None;
let from_or_range_or_to = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
let to = parts.next();
debug_assert!(parts.next().is_none());
let to = if let Some(to) = to {
from = Some(from_or_range_or_to.parse().map_err(|_| {
RequestParserError::SyntaxError(0, from_or_range_or_to.to_string())
})?);
to.parse()
.map_err(|_| RequestParserError::SyntaxError(0, to.to_string()))?
} else {
from_or_range_or_to
.parse()
.map_err(|_| RequestParserError::SyntaxError(0, from_or_range_or_to.to_string()))?
Ok((Request::PlaylistMove(playlist_name, from, to), ""))
}
fn parse_response(
parts: ResponseAttributes<'_>,
) -> Result<Self::Response, ResponseParserError> {
debug_assert!(parts.is_empty());
Ok(())