diff options
author | David Li <li.davidm96@gmail.com> | 2015-11-02 17:39:28 -0500 |
---|---|---|
committer | David Li <li.davidm96@gmail.com> | 2015-11-02 17:39:28 -0500 |
commit | fc0ef639499765507cc0ab7718b5cbc87eebdb96 (patch) | |
tree | eb331ea7ddd3cf41d87dc8d2dfa7ec6413da0804 /src/pushbullet/user.rs | |
parent | 4554b2a4533181886446985c9858f1e49deb4670 (diff) |
Implement user info
Diffstat (limited to 'src/pushbullet/user.rs')
-rw-r--r-- | src/pushbullet/user.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/pushbullet/user.rs b/src/pushbullet/user.rs new file mode 100644 index 0000000..c22dfdd --- /dev/null +++ b/src/pushbullet/user.rs @@ -0,0 +1,21 @@ +extern crate rustc_serialize; + +use rustc_serialize::{json, Decodable, Decoder}; + +#[derive(RustcDecodable,Debug)] +pub struct User { + iden: String, + email: String, + email_normalized: String, + name: String, + image_url: String, + max_upload_size: i32, +} + +impl User { + pub fn parse(user: &str) -> Result<User, json::DecoderError> { + let json = try!(json::Json::from_str(user)); + let mut decoder = json::Decoder::new(json); + Decodable::decode(&mut decoder) + } +} |