Hi, dumb question. It's quite possibly answered elsewhere, but I can't find anything.
I have yaml files like so:
point-list:
- ra: 0.0
dec: 1.0
comp_type: point
flux_type:
list:
- freq: 150e6
i: 1.0
point-power-law:
- ra: 1.0
dec: 2.0
comp_type: point
flux_type:
power_law:
si: -0.8
fd:
freq: 150e6
i: 1.0
The top-levels are Source
s, which are vectors of SourceComponent
, which is:
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct SourceComponent {
/// Coordinates struct associated with the component.
pub radec: RADec,
/// The type of component.
pub comp_type: ComponentType,
/// The flux densities associated with this component.
pub flux_type: FluxDensityType,
}
FluxDensityType
is an enum with two variants visible in the yaml ("list" and "power_law"). However, when deserializing, I don't know how to handle "flux_type" as the marker of "this is actually a FluxDensityType
(and vice versa when serializing). This feels like a simple thing but I can't work it out. It doesn't look like the serde_with
package helps either. Please help! TIA.