mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
2f7d5edb8a
This allows constructs like: ```rust let residual = match Iq::try_from(stanza) { Ok(iq) => return handle_iq(..), Err(Error::TypeMismatch(_, _, v)) => v, Err(other) => return handle_parse_error(..), }; let residual = match Message::try_from(stanza) { .. }; let residual = .. log::warn!("unhandled object: {:?}", residual); ``` The interesting part of this is that this could be used in a loop over a Vec<Box<dyn FnMut(Element) -> ControlFlow<SomeResult, Element>>, i.e. in a parsing loop for a generic XML/XMPP stream. The advantage is that the stanza.is() check runs only once (in check_self!) and doesn't need to be duplicated outside, and it reduces the use of magic strings. |
||
---|---|---|
.. | ||
examples | ||
src | ||
Cargo.toml | ||
ChangeLog | ||
doap.xml | ||
LICENSE | ||
README.md |
xmpp-parsers
What’s this?
A crate which provides parsers and serialisers for most XMPP elements, to avoid having to deal with XML manually. It validates its inputs by default, and aims at providing useful errors when a particular XML element was invalid.
What license is it under?
MPL-2.0 or later, see the LICENSE
file.