aboutsummaryrefslogtreecommitdiff
path: root/src/pushbullet/user.rs
diff options
context:
space:
mode:
authorDavid Li <li.davidm96@gmail.com>2015-11-02 17:39:28 -0500
committerDavid Li <li.davidm96@gmail.com>2015-11-02 17:39:28 -0500
commitfc0ef639499765507cc0ab7718b5cbc87eebdb96 (patch)
treeeb331ea7ddd3cf41d87dc8d2dfa7ec6413da0804 /src/pushbullet/user.rs
parent4554b2a4533181886446985c9858f1e49deb4670 (diff)
Implement user info
Diffstat (limited to 'src/pushbullet/user.rs')
-rw-r--r--src/pushbullet/user.rs21
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)
+ }
+}