parsers: add streamable parsing
This adds shims which provide FromXml and IntoXml implementations to *all* macro-generated types in `xmpp_parsers`. Mind that this does not cover all types in `xmpp_parsers`, but a good share of them. This is another first step toward real, fully streamed parsing.
This commit is contained in:
parent
14a1d66bf8
commit
cb3da52ba2
7 changed files with 131 additions and 0 deletions
|
|
@ -21,6 +21,9 @@ pub enum Error {
|
|||
/// Attempt to parse text data failed with the provided nested error.
|
||||
TextParseError(Box<dyn std::error::Error + Send + Sync + 'static>),
|
||||
|
||||
/// Generic, unspecified other error.
|
||||
Other(Box<str>),
|
||||
|
||||
/// An element header did not match an expected element.
|
||||
///
|
||||
/// This is only rarely generated: most of the time, a mismatch of element
|
||||
|
|
@ -35,6 +38,7 @@ impl fmt::Display for Error {
|
|||
Self::XmlError(ref e) => write!(f, "xml parse error: {}", e),
|
||||
Self::TextParseError(ref e) => write!(f, "text parse error: {}", e),
|
||||
Self::TypeMismatch => f.write_str("mismatch between expected and actual XML data"),
|
||||
Self::Other(msg) => f.write_str(msg),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -61,6 +65,12 @@ impl From<rxml::strings::Error> for Error {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<std::convert::Infallible> for Error {
|
||||
fn from(other: std::convert::Infallible) -> Self {
|
||||
match other {}
|
||||
}
|
||||
}
|
||||
|
||||
/// Error returned from
|
||||
/// [`FromXml::from_events`][`crate::FromXml::from_events`].
|
||||
#[derive(Debug)]
|
||||
|
|
@ -87,6 +97,12 @@ impl From<Error> for FromEventsError {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<std::convert::Infallible> for FromEventsError {
|
||||
fn from(other: std::convert::Infallible) -> Self {
|
||||
match other {}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for FromEventsError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
|
|
|
|||
Loading…
Reference in a new issue