chore: Reorganize examples and interop crates (#180)

* chore: Reorganize examples and interop crates

* fix interop tests
This commit is contained in:
Lucio Franco
2019-12-12 11:53:15 -05:00
committed by GitHub
parent f096a238ac
commit d9a481baef
69 changed files with 25 additions and 22 deletions
+34
View File
@@ -0,0 +1,34 @@
use serde::Deserialize;
use std::fs::File;
#[derive(Debug, Deserialize)]
struct Feature {
location: Location,
name: String,
}
#[derive(Debug, Deserialize)]
struct Location {
latitude: i32,
longitude: i32,
}
#[allow(dead_code)]
pub fn load() -> Vec<crate::routeguide::Feature> {
let file =
File::open("tonic-examples/data/route_guide_db.json").expect("failed to open data file");
let decoded: Vec<Feature> =
serde_json::from_reader(&file).expect("failed to deserialize features");
decoded
.into_iter()
.map(|feature| crate::routeguide::Feature {
name: feature.name,
location: Some(crate::routeguide::Point {
longitude: feature.location.longitude,
latitude: feature.location.latitude,
}),
})
.collect()
}