mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
xml: XmlRoot add namespace checking
This commit is contained in:
@@ -36,6 +36,7 @@ pub struct StructAttrs {
|
||||
pub container: ContainerAttrs,
|
||||
|
||||
pub root: Option<LitByteStr>,
|
||||
pub ns: Option<LitByteStr>,
|
||||
pub allow_invalid: Flag,
|
||||
}
|
||||
|
||||
|
||||
@@ -51,9 +51,14 @@ impl NamedStruct {
|
||||
let (impl_generics, type_generics, where_clause) = self.generics.split_for_impl();
|
||||
let ident = &self.ident;
|
||||
let root = self.attrs.root.as_ref().expect("No root attribute found");
|
||||
let ns = match &self.attrs.ns {
|
||||
Some(ns) => quote! { Some(#ns) },
|
||||
None => quote! { None },
|
||||
};
|
||||
quote! {
|
||||
impl #impl_generics ::rustical_xml::XmlRoot for #ident #type_generics #where_clause {
|
||||
fn root_tag() -> &'static [u8] { #root }
|
||||
fn root_ns() -> Option<&'static [u8]> { #ns }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user