From 1ba083af3576d20b5c1fc1c6ebacefd91ceb6636 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 4 Jan 2020 13:15:00 +0100 Subject: abconfig: reorg + parse result into struct. --- src/abconfig.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/abconfig.rs') diff --git a/src/abconfig.rs b/src/abconfig.rs index 7957dea..294467a 100644 --- a/src/abconfig.rs +++ b/src/abconfig.rs @@ -15,15 +15,20 @@ // along with this program. If not, see . use crate::{client::Client, error::Error}; +use serde::Deserialize; -pub struct ABConfig; - -pub fn abconfig() -> ABConfig { - ABConfig {} +#[derive(Debug, Deserialize)] +pub struct ABConfig { + pub id: u32, + pub chan: u32, + pub xchan: String, + pub cat: String, + pub k: String, + pub v: String, } -impl ABConfig { - pub fn fetch(&self, client: &Client) -> Result { - client.fetch_stream("abconfig", &()) - } +pub fn fetch(client: &Client) -> Result, Error> { + let payload = client.fetch_stream("abconfig", &())?; + Ok(serde_json::from_str(&payload)?) } + -- cgit v1.2.3