summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-03-29 11:21:02 -0500
committertom barrett <spalf0@gmail.com>2019-03-29 11:21:02 -0500
commit95b3508d2397b64c7c63bd3586e524998f194e36 (patch)
tree494a55b9d1bc41212b05094ce26237efab5e80cd /src
parent4576a80954d57bf2cb8ab3d99b73b75b84b2ce02 (diff)
just moved serde value to a string
Diffstat (limited to 'src')
-rw-r--r--src/mass.rs27
-rw-r--r--src/schema.rs8
2 files changed, 5 insertions, 30 deletions
diff --git a/src/mass.rs b/src/mass.rs
index cbac721..aaf788f 100644
--- a/src/mass.rs
+++ b/src/mass.rs
@@ -31,24 +31,12 @@ pub struct Mass {
pub struct MassEntry {
pub id: Option<i32>,
pub name: String,
- pub pos_x: f64,
- pub pos_y: f64,
- pub pos_z: f64,
- pub vel_x: f64,
- pub vel_y: f64,
- pub vel_z: f64,
- pub type_data: serde_json::Value,
+ pub mass: String,
}
impl MassEntry {
- pub fn to_mass(&self) -> Mass {
- Mass {
- position: Vector::new(self.pos_x, self.pos_y, self.pos_z),
- velocity: Vector::new(self.vel_x, self.vel_y, self.vel_z),
- mass_type: serde_json::from_str(&serde_json::to_string(&self.type_data).unwrap())
- .unwrap(),
- effects: Effects::new(),
- }
+ pub fn to_mass(&self) -> (String, Mass) {
+ (self.name.clone(), serde_json::from_str(&self.mass).unwrap())
}
}
@@ -331,14 +319,7 @@ impl Mass {
MassEntry {
id: None,
name,
- pos_x: self.position.x,
- pos_y: self.position.y,
- pos_z: self.position.z,
- vel_x: self.velocity.x,
- vel_y: self.velocity.y,
- vel_z: self.velocity.z,
- type_data: serde_json::from_str(&serde_json::to_string(&self.mass_type).unwrap())
- .unwrap(),
+ mass: serde_json::to_string(&self).unwrap(),
}
}
}
diff --git a/src/schema.rs b/src/schema.rs
index 71abe49..c258603 100644
--- a/src/schema.rs
+++ b/src/schema.rs
@@ -2,12 +2,6 @@ table! {
masses (id) {
id -> Nullable<Integer>,
name -> Varchar,
- pos_x -> Double,
- pos_y -> Double,
- pos_z -> Double,
- vel_x -> Double,
- vel_y -> Double,
- vel_z -> Double,
- type_data -> Jsonb,
+ mass -> Varchar,
}
}