aboutsummaryrefslogtreecommitdiff
path: root/src/pushbullet/user.rs
blob: c22dfdd532fe4e13e500762d73660c4ee09a6778 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)
    }
}