diff options
author | Andy Wortman <ixineeringeverywhere@gmail.com> | 2017-12-01 01:48:32 -0800 |
---|---|---|
committer | Andy Wortman <ixineeringeverywhere@gmail.com> | 2017-12-01 01:48:32 -0800 |
commit | bbe0e891a7cbb0708e2689b8123bb65a6d8ac7e0 (patch) | |
tree | 6e13adb9cbab7b5fd8d5635d25c01f3c7a027ce9 /src/tw | |
parent | 8ad1d470a11dfe99d28a4f5228a3fef335f692d1 (diff) |
display locked and protected as applicable
Diffstat (limited to 'src/tw')
-rw-r--r-- | src/tw/user.rs | 22 |
1 files changed, 17 insertions, 5 deletions
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()) |