minidom, tokio-xmpp: switch xml parsing to rxml
This commit is contained in:
parent
3901068717
commit
d4a5a8247b
33 changed files with 465 additions and 811 deletions
|
|
@ -20,21 +20,12 @@ pub enum Error {
|
|||
/// An error from quick_xml.
|
||||
XmlError(::quick_xml::Error),
|
||||
|
||||
/// An UTF-8 conversion error.
|
||||
Utf8Error(::std::str::Utf8Error),
|
||||
|
||||
/// An I/O error, from std::io.
|
||||
IoError(::std::io::Error),
|
||||
/// Error from rxml parsing
|
||||
ParserError(rxml::Error),
|
||||
|
||||
/// An error which is returned when the end of the document was reached prematurely.
|
||||
EndOfDocument,
|
||||
|
||||
/// An error which is returned when an element is closed when it shouldn't be
|
||||
InvalidElementClosed,
|
||||
|
||||
/// An error which is returned when an elemet's name contains more colons than permitted
|
||||
InvalidElement,
|
||||
|
||||
/// An error which is returned when an element being serialized doesn't contain a prefix
|
||||
/// (be it None or Some(_)).
|
||||
InvalidPrefix,
|
||||
|
|
@ -42,9 +33,6 @@ pub enum Error {
|
|||
/// An error which is returned when an element doesn't contain a namespace
|
||||
MissingNamespace,
|
||||
|
||||
/// An error which is returned when a comment is to be parsed by minidom
|
||||
NoComments,
|
||||
|
||||
/// An error which is returned when a prefixed is defined twice
|
||||
DuplicatePrefix,
|
||||
}
|
||||
|
|
@ -53,14 +41,10 @@ impl StdError for Error {
|
|||
fn cause(&self) -> Option<&dyn StdError> {
|
||||
match self {
|
||||
Error::XmlError(e) => Some(e),
|
||||
Error::Utf8Error(e) => Some(e),
|
||||
Error::IoError(e) => Some(e),
|
||||
Error::ParserError(e) => Some(e),
|
||||
Error::EndOfDocument => None,
|
||||
Error::InvalidElementClosed => None,
|
||||
Error::InvalidElement => None,
|
||||
Error::InvalidPrefix => None,
|
||||
Error::MissingNamespace => None,
|
||||
Error::NoComments => None,
|
||||
Error::DuplicatePrefix => None,
|
||||
}
|
||||
}
|
||||
|
|
@ -70,21 +54,12 @@ impl std::fmt::Display for Error {
|
|||
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Error::XmlError(e) => write!(fmt, "XML error: {}", e),
|
||||
Error::Utf8Error(e) => write!(fmt, "UTF-8 error: {}", e),
|
||||
Error::IoError(e) => write!(fmt, "IO error: {}", e),
|
||||
Error::ParserError(e) => write!(fmt, "XML parser error: {}", e),
|
||||
Error::EndOfDocument => {
|
||||
write!(fmt, "the end of the document has been reached prematurely")
|
||||
}
|
||||
Error::InvalidElementClosed => {
|
||||
write!(fmt, "the XML is invalid, an element was wrongly closed")
|
||||
}
|
||||
Error::InvalidElement => write!(fmt, "the XML element is invalid"),
|
||||
Error::InvalidPrefix => write!(fmt, "the prefix is invalid"),
|
||||
Error::MissingNamespace => write!(fmt, "the XML element is missing a namespace",),
|
||||
Error::NoComments => write!(
|
||||
fmt,
|
||||
"a comment has been found even though comments are forbidden"
|
||||
),
|
||||
Error::DuplicatePrefix => write!(fmt, "the prefix is already defined"),
|
||||
}
|
||||
}
|
||||
|
|
@ -96,15 +71,9 @@ impl From<::quick_xml::Error> for Error {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<::std::str::Utf8Error> for Error {
|
||||
fn from(err: ::std::str::Utf8Error) -> Error {
|
||||
Error::Utf8Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<::std::io::Error> for Error {
|
||||
fn from(err: ::std::io::Error) -> Error {
|
||||
Error::IoError(err)
|
||||
impl From<rxml::Error> for Error {
|
||||
fn from(err: rxml::Error) -> Error {
|
||||
Error::ParserError(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue