Skip to content

Commit 3fae5da

Browse files
committed
Make the inner bundle of Parented transparent
Signed-off-by: Michael X. Grey <[email protected]>
1 parent a83a94b commit 3fae5da

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

rmf_site_format/src/misc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ pub struct SiteID(pub u32);
476476
#[derive(Serialize, Deserialize, Clone, Debug)]
477477
pub struct Parented<P: RefTrait, T> {
478478
pub parent: P,
479+
#[serde(flatten)]
479480
pub bundle: T,
480481
}
481482

rmf_site_format/src/sdf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,6 @@ mod tests {
870870
..Default::default()
871871
};
872872
let s = yaserde::ser::to_string_with_config(&sdf, &config).unwrap();
873-
std::fs::write("test.sdf", s);
873+
std::fs::write("test.sdf", s).unwrap();
874874
}
875875
}

rmf_site_format/src/site.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ impl Site {
202202
serde_json::to_vec_pretty(self)
203203
}
204204

205+
pub fn to_bytes_json_pretty(&self) -> serde_json::Result<Vec<u8>> {
206+
serde_json::to_vec(self)
207+
}
208+
209+
pub fn to_string_json(&self) -> serde_json::Result<String> {
210+
serde_json::to_string(self)
211+
}
212+
213+
pub fn to_string_json_pretty(&self) -> serde_json::Result<String> {
214+
serde_json::to_string_pretty(self)
215+
}
216+
205217
pub fn from_bytes_ron<'a>(s: &'a [u8]) -> ron::error::SpannedResult<Self> {
206218
ron::de::from_bytes(s)
207219
}
@@ -258,4 +270,12 @@ mod tests {
258270
let site_string = map.to_site().unwrap().to_bytes_json().unwrap();
259271
Site::from_bytes_json(&site_string).unwrap();
260272
}
273+
274+
#[test]
275+
fn produce_json_string() {
276+
let data = std::fs::read("../assets/demo_maps/office.building.yaml").unwrap();
277+
let map = BuildingMap::from_bytes(&data).unwrap();
278+
let text = map.to_site().unwrap().to_string_json_pretty().unwrap();
279+
println!("{text}");
280+
}
261281
}

0 commit comments

Comments
 (0)