xml: Add namespace deserialisation

This commit is contained in:
Lennart
2025-05-10 13:09:22 +02:00
parent 3af9b3b8b4
commit 37eb6df64a
3 changed files with 51 additions and 1 deletions

View File

@@ -246,6 +246,25 @@ impl Field {
})
}
pub fn namespace_branch(&self) -> Option<proc_macro2::TokenStream> {
if self.attrs.xml_ty != FieldType::Namespace {
return None;
}
let builder_field_ident = self.builder_field_ident();
let value = quote! {
if let ::quick_xml::name::ResolveResult::Bound(ns) = &ns {
Some(rustical_xml::ValueDeserialize::deserialize(&String::from_utf8_lossy(ns.0.as_ref()))?)
} else {
None
}
};
Some(quote! {
builder.#builder_field_ident = #value;
})
}
pub fn tagname_branch(&self) -> Option<proc_macro2::TokenStream> {
if self.attrs.xml_ty != FieldType::TagName {
return None;