1
use std::collections::HashMap;
2

            
3
use crate::{
4
    commands::{
5
        Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
6
        get_and_parse_property,
7
    },
8
    common::VolumeValue,
9
};
10

            
11
pub struct GetVol;
12

            
13
impl Command for GetVol {
14
    type Response = VolumeValue;
15
    const COMMAND: &'static str = "getvol";
16

            
17
    fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
18
        debug_assert!(parts.next().is_none());
19
        Ok((Request::GetVol, ""))
20
    }
21

            
22
    fn parse_response(
23
        parts: ResponseAttributes<'_>,
24
    ) -> Result<Self::Response, ResponseParserError> {
25
        let parts: HashMap<_, _> = parts.into();
26
        assert_eq!(parts.len(), 1);
27
        let volume = get_and_parse_property!(parts, "volume", Text);
28
        Ok(volume)
29
    }
30
}