Expand description
Async I/O entry points — feature tokio.
The parser itself is synchronous and CPU-bound; async support
here is the standard “slurp bytes via async I/O, then hand to
the existing parser” pattern. It doesn’t parse incrementally
across .await points — for that, use the streaming reader
(crate::Iterparse / crate::XmlReader) on bytes you’ve
already collected.
§Example
use sup_xml::async_io::parse_async;
// Any `tokio::io::AsyncRead` works — `tokio::fs::File` (under
// the `fs` tokio feature), a TCP stream, a `&[u8]` cursor, etc.
let bytes: &[u8] = b"<r><a>hi</a></r>";
let doc = parse_async(bytes).await?;
println!("root: {}", doc.root().name());Bounded-memory usage: callers that don’t trust their input
should wrap the reader in tokio::io::AsyncReadExt::take(MAX)
before passing.
Functions§
- parse_
async - Read
readerto end asynchronously, then parse the bytes. Uses defaultParseOptions. - parse_
async_ with - Like
parse_asyncbut consults the suppliedParseOptions(e.g.recovery_mode: true,external_resolver: Some(...)).