Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.
This repository was archived by the owner on Mar 25, 2024. It is now read-only.

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

Description

@Masber

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


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions