How to transform fields during serialization using Serde?
<p>How can I apply a transformation to a field before serialization?</p>

<p>For example, how can I ensure that the fields <code>lat</code> and <code>lon</code> in this struct definition are rounded to at most 6 decimal places before being serialized?</p>

<pre><code>#[derive(Debug, Serialize)]
struct NodeLocation {
    #[serde(rename = "nodeId")]
    id: u32,
    lat: f32,
    lon: f32,
}
</code></pre>