diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2020-01-04 13:15:00 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2020-01-04 13:15:00 +0100 |
commit | 1ba083af3576d20b5c1fc1c6ebacefd91ceb6636 (patch) | |
tree | 54a04c60fcd6721ab5c0cb782f1fc2bef38538b7 /src/abconfig.rs | |
parent | 862a3b67d701b3c124e1b682db0cee5fc5b711da (diff) | |
download | rust-zotapi-1ba083af3576d20b5c1fc1c6ebacefd91ceb6636.tar.gz rust-zotapi-1ba083af3576d20b5c1fc1c6ebacefd91ceb6636.tar.bz2 rust-zotapi-1ba083af3576d20b5c1fc1c6ebacefd91ceb6636.zip |
abconfig: reorg + parse result into struct.
Diffstat (limited to 'src/abconfig.rs')
-rw-r--r-- | src/abconfig.rs | 21 |
1 files changed, 13 insertions, 8 deletions
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 <https://www.gnu.org/licenses/>. 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<String, Error> { - client.fetch_stream("abconfig", &()) - } +pub fn fetch(client: &Client) -> Result<Vec<ABConfig>, Error> { + let payload = client.fetch_stream("abconfig", &())?; + Ok(serde_json::from_str(&payload)?) } + |