commands/stats: parse_response
This commit is contained in:
parent
74074bf9c7
commit
184f9fc215
@ -1,7 +1,10 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
get_and_parse_optional_property, get_and_parse_property, Command, Request, RequestParserResult,
|
||||||
|
ResponseAttributes, ResponseParserError,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Stats;
|
pub struct Stats;
|
||||||
@ -30,6 +33,24 @@ impl Command for Stats {
|
|||||||
fn parse_response(
|
fn parse_response(
|
||||||
parts: ResponseAttributes<'_>,
|
parts: ResponseAttributes<'_>,
|
||||||
) -> Result<Self::Response, ResponseParserError> {
|
) -> Result<Self::Response, ResponseParserError> {
|
||||||
todo!()
|
let parts: HashMap<_, _> = parts.into();
|
||||||
|
|
||||||
|
let uptime = get_and_parse_property!(parts, "uptime", Text);
|
||||||
|
let playtime = get_and_parse_property!(parts, "playtime", Text);
|
||||||
|
let artists = get_and_parse_optional_property!(parts, "artists", Text);
|
||||||
|
let albums = get_and_parse_optional_property!(parts, "albums", Text);
|
||||||
|
let songs = get_and_parse_optional_property!(parts, "songs", Text);
|
||||||
|
let db_playtime = get_and_parse_optional_property!(parts, "db_playtime", Text);
|
||||||
|
let db_update = get_and_parse_optional_property!(parts, "db_update", Text);
|
||||||
|
|
||||||
|
Ok(StatsResponse {
|
||||||
|
uptime,
|
||||||
|
playtime,
|
||||||
|
artists,
|
||||||
|
albums,
|
||||||
|
songs,
|
||||||
|
db_playtime,
|
||||||
|
db_update,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user