pub async fn from_xml_stream_async<R: AsyncRead + Unpin + Send + 'static>(
reader: R,
config: &StreamConfig,
) -> Result<AsyncXmlStream<R>, String>Expand description
Create an async streaming XML parser
This function returns a stream that yields items incrementally, allowing processing of files larger than available RAM.
§Examples
use hedl_xml::async_api::from_xml_stream_async;
use hedl_xml::streaming::StreamConfig;
use tokio::fs::File;
let file = File::open("large.xml").await?;
let config = StreamConfig::default();
let mut stream = from_xml_stream_async(file, &config).await?;
let mut count = 0;
while let Some(result) = stream.next().await {
match result {
Ok(_item) => count += 1,
Err(e) => eprintln!("Parse error: {}", e),
}
}
println!("Processed {} items", count);§Errors
Returns an error if the stream cannot be initialized.