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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// "kernel": {
//       "id": 2233,
//       "name": "Ubuntu 14.04 x64 vmlinuz-3.13.0-37-generic",
//       "version": "3.13.0-37-generic"
//     },

use std::fmt;
use std::borrow::Cow;

use response::NamedResponse;
use response;

#[derive(Deserialize, Debug)]
pub struct Kernel {
    pub id: f64,
    pub name: String,
    pub version: String,
}

impl response::NotArray for Kernel {}

impl fmt::Display for Kernel {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
       write!(f, "ID: {:.0}\n\
                  Name: {}\n\
                  Version:{}",
                self.id,
                self.name,
                self.version)
    }
}

impl NamedResponse for Kernel {
    fn name<'a>() -> Cow<'a, str> {
        "kernel".into()
    }
}

pub type Kernels = Vec<Kernel>;