aboutsummaryrefslogtreecommitdiff
path: root/src/pushbullet/user.rs
diff options
context:
space:
mode:
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)
+ }
+}