tafia / quick-xml

Rust high performance xml reader and writer
MIT License
1.23k stars 239 forks source link

Unexpected Error on Deserialization #277

Closed HTGAzureX1212 closed 3 years ago

HTGAzureX1212 commented 3 years ago

I currently have the following XML for deserialization:

<Levels>
    <CensorshipLevel Level="0" />
</Levels>

Which I wrote the following Rust code for it:

extern crate serde;
extern crate quick_xml;

#[derive(Debug, Clone, Serialize, Deserialize)]
crate struct CensorshipLevel {
    #[serde(rename = "Level")]
    crate level: u8
}

However, when I attempt to deserialize it, I see this in my logs:

[src\system\event_handler.rs:266] quick_xml::de::from_str::<BotConfig>(&config_string) = Err(
    Custom(
        "missing field `Level`",
    ),
)

Saying that the field Level is missing.

How can I fix this issue?

HTGAzureX1212 commented 3 years ago

Typically the code that handles the XML deserialization is located here:

https://github.com/HT-Studios/HarTex-rust-discord-bot/tree/infdev/src/xml_deserialization

Just in case additional information on my implementation is required.

HTGAzureX1212 commented 3 years ago

Any help is appreciated.