1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//! User-related data structures.

use api::types::*;

use rustc_serialize::{Decodable, Decoder };

/// # User
/// Represents an authorized user for a given product.
#[derive(Debug)]
pub struct User {
    /// The access token for this user
    pub access_token: AccessToken
}

impl Decodable for User {

    fn decode<D: Decoder>(decoder: &mut D) -> Result<User, D::Error> {
        decoder.read_struct("root", 3, |decoder| {
            Ok(User {
                access_token: try!(decoder.read_struct_field("access_token", 0, |d| Decodable::decode(d)))
            })
        })
    }

}