dtolnay/serde-yaml

Why is it trying to deserialize a map instead of an enum?

Opened this issue · 0 comments

Deal serde_yaml community,

I have these structs and entity:

#[derive(Deserialize, Serialize, Debug)]
pub struct Ims {
    name: String,
    r#type: String,
}

#[derive(Deserialize, Serialize, Debug)]
pub struct Product {
    name: String,
    version: String,
    r#type: String,
}

#[derive(Deserialize, Serialize, Debug)]
pub enum ImageBase {
    Ims { ims: Ims },
    Product { product: Product },
    ImageRef { image_ref: String },
}

#[derive(Deserialize, Serialize, Debug)]
pub struct SatFileImage {
    pub name: String,
    pub base: ImageBase,
    pub configuration: Option<String>,
    pub configuration_group_names: Option<Vec<String>>,
    pub ref_name: Option<String>,
    pub description: Option<String>,
}

I have a yaml like

- name: my-name
  base:
    ims:
      name: my-name
      type: image
  configuration: my-configuration
  configuration_group_names:
  - Compute

And this fails with the following error:

Err(
    Error("invalid type: map, expected a Value::Tagged enum"),
)

Any idea why am I getting this error?

kind regards