1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use parsing::{IsOk, HttpResponseHead, ResponseBody, Unbuffered, MaybeOkResponse};
use error::*;
#[derive(Deserialize, Debug, Clone)]
pub struct CommandResponse {
acknowledged: bool
}
impl CommandResponse {
pub fn acknowledged(&self) -> bool {
self.acknowledged
}
}
impl IsOk for CommandResponse {
fn is_ok<B: ResponseBody>(head: HttpResponseHead, body: Unbuffered<B>) -> Result<MaybeOkResponse<B>, ParseResponseError> {
match head.status() {
200...299 => Ok(MaybeOkResponse::ok(body)),
_ => Ok(MaybeOkResponse::err(body)),
}
}
}