RReverser / serde-xml-rs

xml-rs based deserializer for Serde (compatible with 1.0+)
https://crates.io/crates/serde-xml-rs
MIT License
273 stars 92 forks source link

duplicate field `$value`' #201

Open codingatc opened 1 year ago

codingatc commented 1 year ago

I am processing the following file. https://github.com/KhronosGroup/OpenGL-Registry/blob/main/xml/gl.xml

It has lines such as this:

            <proto><ptype>GLVULKANPROCNV</ptype> <name>glGetVkProcAddrNV</name></proto>
            <proto>void <name>glWaitVkSemaphoreNV</name></proto>

So I would like to sometimes extract the string under proto, or the ptype, but always get the name, as it is always present. However:

#[derive(Debug, Deserialize, PartialEq)]
struct Proto {
    #[serde(rename = "$value")]
    return_type: String,
    ptype: Option<String>,
    name: String,
}

Doesn't work. Is there a way to state that return_type should only have the non-fields of the xml member proto?