pub struct HtmlReader { /* private fields */ }Expand description
A streaming HTML reader that implements EventSource.
HtmlReader parses HTML using html5gum and emits DocSpec events
one at a time. Only <p> paragraph elements are recognized; all other
elements are silently ignored.
§Example
use docspec_html_reader::{HtmlReader, EventSource};
let mut reader = HtmlReader::from_str("<p>hello</p>");
while let Some(event) = reader.next_event()? {
// Process events...
}Implementations§
Source§impl HtmlReader
impl HtmlReader
Sourcepub fn from_reader<R: Read + Seek + Send + 'static>(reader: R) -> Result<Self>
pub fn from_reader<R: Read + Seek + Send + 'static>(reader: R) -> Result<Self>
Creates an HtmlReader from any Read + Seek source.
The source is streamed via html5gum::IoReader’s 16 KB sliding-window
buffer. Memory usage is constant regardless of document size.
The Seek bound is required for API symmetry with other DocSpec readers
(e.g., DocxReader), even though html5gum::IoReader only needs Read.
§Errors
This constructor does not read from the source eagerly and therefore currently cannot fail.
Trait Implementations§
Source§impl EventSource for HtmlReader
impl EventSource for HtmlReader
Auto Trait Implementations§
impl !RefUnwindSafe for HtmlReader
impl !Sync for HtmlReader
impl !UnwindSafe for HtmlReader
impl Freeze for HtmlReader
impl Send for HtmlReader
impl Unpin for HtmlReader
impl UnsafeUnpin for HtmlReader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more