Expand description
Restricted XML parsing and encoding
This crate provides “restricted” parsing and encoding of XML 1.0 documents with namespacing.
Features (some call them restrictions)
- No external resources
- No custom entities
- No DTD whatsoever
- No processing instructions
- No comments
- UTF-8 only
- Namespacing-well-formedness enforced
- XML 1.0 only
- Streamed parsing (parser emits a subset of SAX events)
- Streamed encoding
- Parser can be driven push- and pull-based
- Tokio-based asynchronicity supported via the
async
feature andAsyncParser
.
Example
use rxml::EventRead;
let doc = b"<?xml version='1.0'?><hello>World!</hello>";
let mut fp = rxml::FeedParser::default();
let result = rxml::as_eof_flag(fp.parse_all(&mut &doc[..], true, |ev| {
println!("got event: {:?}", ev);
}));
// true indicates eof
assert_eq!(result.unwrap(), true);
High-level parser usage
Push-based usage
The FeedParser
allows to push bits of XML into the parser as they arrive
in the application and process the resulting ResolvedEvent
s as they
happen.
Pull-based usage
If the parser should block while waiting for more data to arrive, a
PullParser
can be used instead. The PullParser
requires a source which
implements io::BufRead
.
Usage with Tokio
Tokio is supported with the async
feature. It offers the AsyncParser
and the AsyncEventRead
trait, which work similar to the PullParser
.
Instead of blocking, however, the async parser will yield control to other
tasks.
Re-exports
pub use strings::CData;
pub use strings::CDataStr;
pub use strings::Name;
pub use strings::NameStr;
pub use strings::NcName;
pub use strings::NcNameStr;
pub use bytes;
Modules
Error types
XML 1.0 Lexer
Restricted XML 1.0 parsing facilities
Strongly-typed strings for use with XML 1.0 documents
Writer for restricted XML 1.0
Macros
Compile-time conversion of a string literal to NcNameStr
Structs
Asynchronous driver for parsers
Zero-copy buffered reader for a queue of byte slices.
Shared context for multiple parsers
Encodes XML into buffers.
Restricted XML 1.0 lexer
Wrapper around Lexer
and std::io::BufRead
to provide
a TokenRead
.
Hold options to configure a Lexer
.
Namespace/Attribute resolver
Low-level restricted XML 1.0 parser
Blocking driver for parsers
Non-blocking driver for parsers
Low-level, logical restricted XML 1.0 parser
Enums
Error types which may be returned from the parser or lexer.
An encodable item.
Logical XML document parts
High-level, logical XML document parts
XML version number
Constants
Package version
XML core namespace URI (for the xml:
prefix)
XML namespace URI (for the xmlns:
prefix)
Traits
Asynchronous source of individual XML events
Helper trait for asynchronous sources of individual XML events
Source for individual XML events
Trait for parser-like structs.
Trait for things which can be constructed with a context::Context
.
Functions
Convert end-of-file-ness of a result to a boolean flag.
Type Definitions
Tokio-compatible asynchronous parser
Compatibility alias, use ResolvedEvent
directly instead.
Non-blocking parsing
Blocking parsing
Compatibility alias, use ResolvedQName
directly instead.
Pair of an optional namespace prefix and a localpart, commonly used in element and attribute names.
Pair of an optional namespace name (URI) and a localpart, commonly used in element and attribute names.
Compatibility alias, use XmlVersion
directly instead.