2019-07-14 22:43:57 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2019-08-04 23:17:39 +00:00
|
|
|
use std::cmp::Ordering;
|
2019-07-21 23:55:38 +00:00
|
|
|
|
2019-07-14 22:43:57 +00:00
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
pub struct SystemSerde {
|
|
|
|
pub id: u32,
|
|
|
|
pub star_type: String,
|
|
|
|
pub system: String,
|
|
|
|
pub body: String,
|
|
|
|
pub mult: f32,
|
|
|
|
pub distance: u32,
|
|
|
|
pub x: f32,
|
|
|
|
pub y: f32,
|
|
|
|
pub z: f32,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl SystemSerde {
|
|
|
|
pub fn build(&self) -> System {
|
|
|
|
System {
|
|
|
|
id: self.id,
|
|
|
|
star_type: self.star_type.clone(),
|
|
|
|
system: self.system.clone(),
|
|
|
|
body: self.body.clone(),
|
|
|
|
mult: self.mult,
|
|
|
|
distance: self.distance,
|
|
|
|
pos: [self.x, self.y, self.z],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
|
|
pub struct System {
|
|
|
|
pub id: u32,
|
|
|
|
pub star_type: String,
|
|
|
|
pub system: String,
|
|
|
|
pub body: String,
|
|
|
|
pub mult: f32,
|
|
|
|
pub distance: u32,
|
|
|
|
pub pos: [f32; 3],
|
|
|
|
}
|
2019-08-04 22:05:44 +00:00
|
|
|
|
|
|
|
impl Ord for System {
|
|
|
|
fn cmp(&self, other: &Self) -> Ordering {
|
2019-08-05 00:01:52 +00:00
|
|
|
self.id.cmp(&other.id)
|
2019-08-04 22:05:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialOrd for System {
|
|
|
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
2019-08-05 00:01:52 +00:00
|
|
|
Some(self.cmp(other))
|
2019-08-04 22:05:44 +00:00
|
|
|
}
|
|
|
|
}
|