1
use crate::{
2
    commands::{
3
        Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
4
        ResponseParserError,
5
    },
6
    common::PlaylistName,
7
    filter::parse_filter,
8
};
9

            
10
pub struct SearchPlaylist;
11

            
12
impl Command for SearchPlaylist {
13
    type Response = ();
14
    const COMMAND: &'static str = "searchplaylist";
15

            
16
    fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
17
        let name = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
18
        let name = name
19
            .parse::<PlaylistName>()
20
            .map_err(|_| RequestParserError::SyntaxError(0, name.to_owned()))?;
21

            
22
        let filter = parse_filter(&mut parts)?;
23

            
24
        let range = parts
25
            .next()
26
            .map(|s| {
27
                s.parse()
28
                    .map_err(|_| RequestParserError::SyntaxError(0, s.to_owned()))
29
            })
30
            .transpose()?;
31

            
32
        debug_assert!(parts.next().is_none());
33

            
34
        Ok((Request::SearchPlaylist(name, filter, range), ""))
35
    }
36

            
37
    fn parse_response(
38
        parts: ResponseAttributes<'_>,
39
    ) -> Result<Self::Response, ResponseParserError> {
40
        unimplemented!()
41
    }
42
}