1
use crate::commands::{
2
    Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
3
    ResponseParserError,
4
};
5

            
6
pub struct PlaylistDelete;
7

            
8
impl Command for PlaylistDelete {
9
    type Response = ();
10
    const COMMAND: &'static str = "playlistdelete";
11

            
12
    fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
13
        let playlist_name = parts
14
            .next()
15
            .ok_or(RequestParserError::UnexpectedEOF)?
16
            .to_string();
17

            
18
        // TODO: this can be a range, according to docs
19
        let position = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
20
        let position = position
21
            .parse()
22
            .map_err(|_| RequestParserError::SyntaxError(0, position.to_string()))?;
23

            
24
        debug_assert!(parts.next().is_none());
25

            
26
        Ok((Request::PlaylistDelete(playlist_name, position), ""))
27
    }
28

            
29
    fn parse_response(
30
        parts: ResponseAttributes<'_>,
31
    ) -> Result<Self::Response, ResponseParserError> {
32
        debug_assert!(parts.is_empty());
33
        Ok(())
34
    }
35
}