I have a toml file with pairs id and mac like this:
[[component]]
id = 1
mac = "d4:d7:04:c9:85:a4"
[[component]]
id = 3
mac = "3c:21:ee:b4:0d:ab"
[[component]]
id = 6
mac = "ea:f3:23:8c:b8:c1"
The goal is to deserialize this file to a Vec of this struct
(MacAddr6
belongs to the macaddr
crate:
#[derive(Deserialize, Debug)]
pub struct Component {
pub id: u16,
pub mac: MacAddr6,
}
When I try to deserialize, this error is shown:
inner: TomlError { message: "invalid type: string
"d4:d7:04:c9:85:a4", expected an array of length 6"
If I change MacAddr6
to String
in the struct definition and everything worked fine, so I have a workaround. Nevertheless, since MacAddr6
implements serde::Deserialize
and core::str::FromStr
I was expecting to retrieve the full struct in one time. What am I doing wrong?