Deserialization of SVD file using serde-xml-rs


I come from C/C++ world where I have developed xml parser for SVD based on visitor pattern. However, I’m now rewritting the parser in Rust using serde-xml-rs crate and I’ve run into several issues.

The structure of the SVD is defined by ARM []

The first issue is with parsing unsigned numbers:

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct Field {
    name: String,
    description: String,
    bit_offset: u8,
    bit_width: u8

// Tests
let data = r#"
<description>Port x configuration bits (y =

let field: Field = serde_xml_rs::deserialize(data.as_bytes()).unwrap();

assert_eq!(, "MODER15");
assert_eq!(field.description, "Port x configuration bits (y = 0..15)");
assert_eq!(field.bit_offset, 30);
assert_eq!(field.bit_width, 2);

But I get following error: value: invalid type: string “30”, expected u8’.

When I use type i32 it works without any error? Any idea why?