From 24e2e724e0cfdb4e6db3a717ac804ac69c4c8ccc Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Fri, 10 Jan 2020 13:01:54 +0100 Subject: [PATCH] Split conversion of spaces and objects --- src/json/storage.rs | 19 ++++++++----------- src/main.rs | 3 ++- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/json/storage.rs b/src/json/storage.rs index 9a75f1f..fc56f89 100644 --- a/src/json/storage.rs +++ b/src/json/storage.rs @@ -60,18 +60,15 @@ where bincode::serialize_into(writer, &data).unwrap(); } -pub fn convert(name: &str) { - // Convert Reference Space definitions - let fn_in = format!("{}.spaces.json", name); - let fn_out = format!("{}.spaces.bin", name); +pub fn convert(name: &str) +where + T: Serialize + DeserializeOwned, +{ + // Convert definitions from json to bincode + let fn_in = format!("{}.json", name); + let fn_out = format!("{}.bin", name); - from_json::>(&fn_in, &fn_out); - - // Convert Spatial Objects - let fn_in = format!("{}.objects.json", name); - let fn_out = format!("{}.objects.bin", name); - - from_json::>(&fn_in, &fn_out); + from_json::(&fn_in, &fn_out); } pub fn build( diff --git a/src/main.rs b/src/main.rs index ec942af..5b3d0f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,8 @@ fn main() { // Convert to binary the JSON data: if true { info_time!("Converting to binary JSON data"); - storage::convert("10k"); + storage::convert::>("10k.spaces"); + storage::convert::>("10k.objects"); } // Build a Database Index: