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

            
8
pub struct Prio;
9

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

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

            
20
        let window = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
21
        let window = window
22
            .parse()
23
            .map_err(|_| RequestParserError::SyntaxError(0, window.to_string()))?;
24

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

            
27
        Ok((Request::Prio(prio, window), ""))
28
    }
29

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