From fc0ef639499765507cc0ab7718b5cbc87eebdb96 Mon Sep 17 00:00:00 2001
From: David Li
Date: Mon, 2 Nov 2015 17:39:28 -0500
Subject: Implement user info
---
src/pushbullet/user.rs | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 src/pushbullet/user.rs
(limited to 'src/pushbullet/user.rs')
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 {
+ let json = try!(json::Json::from_str(user));
+ let mut decoder = json::Decoder::new(json);
+ Decodable::decode(&mut decoder)
+ }
+}
--
cgit v1.2.3