From 50654583a0c8f51c58f4138a3d2564036e3f2855 Mon Sep 17 00:00:00 2001 From: iximeow Date: Fri, 1 Dec 2017 01:48:32 -0800 Subject: display locked and protected as applicable --- src/tw/user.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/tw/user.rs') diff --git a/src/tw/user.rs b/src/tw/user.rs index 86fbe3f..4fde026 100644 --- a/src/tw/user.rs +++ b/src/tw/user.rs @@ -4,7 +4,11 @@ extern crate serde_json; pub struct User { pub id: String, pub name: String, - pub handle: String + pub handle: String, + #[serde(default)] + pub protected: bool, + #[serde(default)] + pub verified: bool } impl Default for User { @@ -12,7 +16,9 @@ impl Default for User { User { id: "".to_owned(), name: "_default_".to_owned(), - handle: "_default_".to_owned() + handle: "_default_".to_owned(), + protected: false, + verified: false } } } @@ -23,16 +29,22 @@ impl User { if let ( Some(id_str), Some(name), - Some(screen_name) + Some(screen_name), + Some(protected), + Some(bluecheck) ) = ( json_map.get("id_str").and_then(|x| x.as_str()), json_map.get("name").and_then(|x| x.as_str()), - json_map.get("screen_name").and_then(|x| x.as_str()) + json_map.get("screen_name").and_then(|x| x.as_str()), + json_map.get("protected").and_then(|x| x.as_bool()), + json_map.get("verified").and_then(|x| x.as_bool()) ) { Ok(User { id: id_str.to_owned(), name: name.to_owned(), - handle: screen_name.to_owned() + handle: screen_name.to_owned(), + protected: protected.to_owned(), + verified: bluecheck.to_owned() }) } else { Err("user json missing one of id_str, name, screen_name".to_owned()) -- cgit v1.1