summaryrefslogtreecommitdiff
path: root/src/astroid.rs
blob: 0eed4ff88dcf307fff2a68a442a8443ab2a3794e (plain)
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
use mass::Mass;
extern crate serde_json;

#[derive(Serialize, Deserialize, Debug)]
pub struct Astroid {
    name        : String,
    location    : (f64, f64, f64),
}

impl Mass for Astroid {
    fn new(name : &str, location : (f64, f64, f64)) -> Astroid {
        Astroid {
            name : String::from(name),
            location : location,
        }
    }

    fn name(&self) -> &String {
        &self.name
    }

    fn location(&self) -> (f64, f64, f64) {
        self.location
    }

    fn set_location(&mut self, location : (f64, f64, f64)) {
        self.location = location;
    }

    fn serialize(&self) ->String {
        serde_json::to_string(self).unwrap()
    }

    fn deserialize(&mut self, data : &str) {
    }
}