Open
Description
My objective is to create a XML element that has the following format:
<?xml version="1.0" encoding="UTF-8"?>
<Camera>
<definition version="42">
<model>Potato</model>
<vendor>PotatoFarm</vendor>
</definition>
</Camera>
But to accomplish that, from what I read from the examples, is necessary to create a structure like this one:
#[derive(Debug, Default, Serialize)]
struct Camera {
definition: Definition,
}
#[derive(Debug, Default, Serialize)]
struct Definition {
version: u32,
model: Model,
vendor: Vendor,
}
#[derive(Debug, Default, Serialize)]
struct Model {
#[serde(rename = "$value")]
body: String,
}
#[derive(Debug, Default, Serialize)]
struct Vendor {
#[serde(rename = "$value")]
body: String,
}
Is these struct with body element really necessary or is there a way to accomplish it with a macro or something to a simple struct like:
#[derive(Debug, Default, Serialize)]
struct Camera {
definition: Definition,
}
#[derive(Debug, Default, Serialize)]
struct Definition {
#[magic_macro]
camera_info: CameraInfo,
}
#[derive(Debug, Default, Serialize)]
struct CameraInfo {
vendor: String,
model: String,
}