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

            
6
pub struct Repeat;
7

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

            
12
    fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
13
        let state = match parts.next() {
14
            Some("0") => false,
15
            Some("1") => true,
16
            Some(s) => return Err(RequestParserError::SyntaxError(0, s.to_owned())),
17
            None => return Err(RequestParserError::UnexpectedEOF),
18
        };
19

            
20
        debug_assert!(parts.next().is_none());
21

            
22
        Ok((Request::Repeat(state), ""))
23
    }
24

            
25
    fn parse_response(
26
        parts: ResponseAttributes<'_>,
27
    ) -> Result<Self::Response, ResponseParserError> {
28
        debug_assert!(parts.is_empty());
29
        Ok(())
30
    }
31
}