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