1
use std::str::FromStr;
2

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

            
8
pub struct Single;
9

            
10
impl Command for Single {
11
    type Response = ();
12
    const COMMAND: &'static str = "single";
13

            
14
    fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
15
        let state = match parts.next() {
16
            Some(s) => crate::common::BoolOrOneshot::from_str(s)
17
                .map_err(|_| RequestParserError::SyntaxError(0, s.to_owned()))?,
18
            None => return Err(RequestParserError::UnexpectedEOF),
19
        };
20

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

            
23
        Ok((Request::Single(state), ""))
24
    }
25

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