1
use std::collections::HashMap;
2

            
3
use serde::{Deserialize, Serialize};
4

            
5
use crate::{
6
    commands::{CommandResponse, ResponseParserError, single_optional_item_command_request},
7
    response_tokenizer::{ResponseAttributes, get_and_parse_property},
8
    types::Uri,
9
};
10

            
11
single_optional_item_command_request!(Update, "update", Uri);
12

            
13
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
14
pub struct UpdateResponse {
15
    updating_db: usize,
16
}
17

            
18
impl UpdateResponse {
19
    pub fn new(updating_db: usize) -> Self {
20
        UpdateResponse { updating_db }
21
    }
22
}
23

            
24
impl CommandResponse for UpdateResponse {
25
    type Request = UpdateRequest;
26

            
27
    fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
28
        let parts: HashMap<_, _> = parts.into_map()?;
29

            
30
        let updating_db = get_and_parse_property!(parts, "updating_db", Text);
31

            
32
        Ok(UpdateResponse { updating_db })
33
    }
34

            
35
    fn serialize(&self) -> Vec<u8> {
36
        unimplemented!("response serialization is not yet implemented for UpdateResponse")
37
    }
38
}