mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 12:52:27 +00:00
xml: Rename XmlDeError to XmlError
This commit is contained in:
@@ -158,7 +158,7 @@ impl Field {
|
||||
(false, false, true) => quote! { builder.#builder_field_ident },
|
||||
(false, false, false) => {
|
||||
let field_ident = self.field_ident().into_token_stream().to_string();
|
||||
quote! { builder.#builder_field_ident.ok_or(::rustical_xml::XmlDeError::MissingField(#field_ident))? }
|
||||
quote! { builder.#builder_field_ident.ok_or(::rustical_xml::XmlError::MissingField(#field_ident))? }
|
||||
}
|
||||
};
|
||||
quote! { #target_field_index: #builder_value }
|
||||
|
||||
@@ -28,10 +28,10 @@ impl Enum {
|
||||
reader: &mut quick_xml::NsReader<R>,
|
||||
start: &quick_xml::events::BytesStart,
|
||||
empty: bool
|
||||
) -> Result<Self, rustical_xml::XmlDeError> {
|
||||
) -> Result<Self, rustical_xml::XmlError> {
|
||||
#(#variant_branches);*
|
||||
|
||||
Err(rustical_xml::XmlDeError::InvalidVariant("could not match".to_owned()))
|
||||
Err(rustical_xml::XmlError::InvalidVariant("could not match".to_owned()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,14 +49,14 @@ impl Enum {
|
||||
reader: &mut quick_xml::NsReader<R>,
|
||||
start: &quick_xml::events::BytesStart,
|
||||
empty: bool
|
||||
) -> Result<Self, rustical_xml::XmlDeError> {
|
||||
) -> Result<Self, rustical_xml::XmlError> {
|
||||
let (_ns, name) = reader.resolve_element(start.name());
|
||||
|
||||
match name.as_ref() {
|
||||
#(#variant_branches),*
|
||||
name => {
|
||||
// Handle invalid variant name
|
||||
Err(rustical_xml::XmlDeError::InvalidVariant(String::from_utf8_lossy(name).to_string()))
|
||||
Err(rustical_xml::XmlError::InvalidVariant(String::from_utf8_lossy(name).to_string()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ impl Enum {
|
||||
|
||||
quote! {
|
||||
impl #impl_generics ::rustical_xml::XmlDocument for #ident #type_generics #where_clause {
|
||||
fn parse<R: ::std::io::BufRead>(mut reader: ::quick_xml::NsReader<R>) -> Result<Self, ::rustical_xml::XmlDeError>
|
||||
fn parse<R: ::std::io::BufRead>(mut reader: ::quick_xml::NsReader<R>) -> Result<Self, ::rustical_xml::XmlError>
|
||||
where
|
||||
Self: ::rustical_xml::XmlDeserialize
|
||||
{
|
||||
@@ -166,26 +166,26 @@ impl Enum {
|
||||
return <Self as ::rustical_xml::XmlDeserialize>::deserialize(&mut reader, &start, empty);
|
||||
}
|
||||
|
||||
Event::Eof => return Err(::rustical_xml::XmlDeError::Eof),
|
||||
Event::Eof => return Err(::rustical_xml::XmlError::Eof),
|
||||
Event::Text(bytes_text) => {
|
||||
return Err(::rustical_xml::XmlDeError::UnsupportedEvent("Text"));
|
||||
return Err(::rustical_xml::XmlError::UnsupportedEvent("Text"));
|
||||
}
|
||||
Event::CData(cdata) => {
|
||||
return Err(::rustical_xml::XmlDeError::UnsupportedEvent("CDATA"));
|
||||
return Err(::rustical_xml::XmlError::UnsupportedEvent("CDATA"));
|
||||
}
|
||||
Event::Comment(_) => { /* ignore */ }
|
||||
Event::Decl(_) => {
|
||||
/* ignore */
|
||||
// return Err(::rustical_xml::XmlDeError::UnsupportedEvent("Declaration"));
|
||||
// return Err(::rustical_xml::XmlError::UnsupportedEvent("Declaration"));
|
||||
}
|
||||
Event::PI(_) => {
|
||||
return Err(::rustical_xml::XmlDeError::UnsupportedEvent("Processing instruction"));
|
||||
return Err(::rustical_xml::XmlError::UnsupportedEvent("Processing instruction"));
|
||||
}
|
||||
Event::DocType(doctype) => {
|
||||
return Err(::rustical_xml::XmlDeError::UnsupportedEvent("Doctype in the middle of the document"));
|
||||
return Err(::rustical_xml::XmlError::UnsupportedEvent("Doctype in the middle of the document"));
|
||||
}
|
||||
Event::End(end) => {
|
||||
return Err(::rustical_xml::XmlDeError::UnsupportedEvent("Premature end"));
|
||||
return Err(::rustical_xml::XmlError::UnsupportedEvent("Premature end"));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ fn invalid_field_branch(ident: &syn::Ident, allow: bool) -> proc_macro2::TokenSt
|
||||
quote! {}
|
||||
} else {
|
||||
quote! {
|
||||
return Err(XmlDeError::InvalidFieldName(#ident, format!("[{ns:?}]{tag}", tag = String::from_utf8_lossy(tag)))) }
|
||||
return Err(XmlError::InvalidFieldName(#ident, format!("[{ns:?}]{tag}", tag = String::from_utf8_lossy(tag)))) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,9 +130,9 @@ impl NamedStruct {
|
||||
reader: &mut quick_xml::NsReader<R>,
|
||||
start: &quick_xml::events::BytesStart,
|
||||
empty: bool
|
||||
) -> Result<Self, rustical_xml::XmlDeError> {
|
||||
) -> Result<Self, rustical_xml::XmlError> {
|
||||
use quick_xml::events::Event;
|
||||
use rustical_xml::XmlDeError;
|
||||
use rustical_xml::XmlError;
|
||||
|
||||
let mut buf = Vec::new();
|
||||
|
||||
@@ -163,7 +163,7 @@ impl NamedStruct {
|
||||
Event::End(e) if e.name() == start.name() => {
|
||||
break;
|
||||
}
|
||||
Event::Eof => return Err(XmlDeError::Eof),
|
||||
Event::Eof => return Err(XmlError::Eof),
|
||||
// start of a child element
|
||||
Event::Start(start) | Event::Empty(start) => {
|
||||
let empty = matches!(event, Event::Empty(_));
|
||||
@@ -179,24 +179,24 @@ impl NamedStruct {
|
||||
#(#text_field_branches)*
|
||||
}
|
||||
Event::CData(cdata) => {
|
||||
return Err(XmlDeError::UnsupportedEvent("CDATA"));
|
||||
return Err(XmlError::UnsupportedEvent("CDATA"));
|
||||
}
|
||||
Event::Comment(_) => { /* ignore */ }
|
||||
Event::Decl(_) => {
|
||||
// Error: not supported
|
||||
return Err(XmlDeError::UnsupportedEvent("Declaration"));
|
||||
return Err(XmlError::UnsupportedEvent("Declaration"));
|
||||
}
|
||||
Event::PI(_) => {
|
||||
// Error: not supported
|
||||
return Err(XmlDeError::UnsupportedEvent("Processing instruction"));
|
||||
return Err(XmlError::UnsupportedEvent("Processing instruction"));
|
||||
}
|
||||
Event::DocType(doctype) => {
|
||||
// Error: start of new document
|
||||
return Err(XmlDeError::UnsupportedEvent("Doctype in the middle of the document"));
|
||||
return Err(XmlError::UnsupportedEvent("Doctype in the middle of the document"));
|
||||
}
|
||||
Event::End(end) => {
|
||||
// Error: premature end
|
||||
return Err(XmlDeError::Other("Unexpected closing tag for wrong element".to_owned()));
|
||||
return Err(XmlError::Other("Unexpected closing tag for wrong element".to_owned()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user