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
asyncfeature 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 ResolvedEvents 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::NCName;pub use strings::NCNameStr;pub use strings::Name;pub use strings::NameStr;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
XML 1.0 CData compliant string
XML 1.0 Name compliant string
Namespaces for XML 1.0 NCName compliant string
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
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.