pub struct HtmlReader<'src> { /* private fields */ }Expand description
Pull-based HTML event reader (XmlReader twin). Iterate events
with next(); the reader feeds the next 8 KiB chunk into
html5ever whenever its internal queue runs dry.
§Example
use sup_xml_core::html::{HtmlReader, HtmlEvent};
let mut r = HtmlReader::new("<p>hello <b>world</b></p>");
loop {
match r.next().unwrap() {
HtmlEvent::Eof => break,
HtmlEvent::StartElement { name, .. } => println!("start: {name}"),
_ => {}
}
}Implementations§
Source§impl<'src> HtmlReader<'src>
impl<'src> HtmlReader<'src>
pub fn new(input: &'src str) -> HtmlReader<'src>
pub fn with_opts(input: &'src str, opts: HtmlParseOptions) -> HtmlReader<'src>
Sourcepub fn next(&mut self) -> Result<HtmlEvent<'_>, XmlError>
pub fn next(&mut self) -> Result<HtmlEvent<'_>, XmlError>
Pull the next event. Returns Eof when input is exhausted.
Sourcepub fn recovered_errors(&self) -> &[XmlError]
pub fn recovered_errors(&self) -> &[XmlError]
Errors recovered while parsing (only populated in lenient
mode). Strict mode returns an Err from next() instead.
Auto Trait Implementations§
impl<'src> !Freeze for HtmlReader<'src>
impl<'src> !RefUnwindSafe for HtmlReader<'src>
impl<'src> !Send for HtmlReader<'src>
impl<'src> !Sync for HtmlReader<'src>
impl<'src> Unpin for HtmlReader<'src>
impl<'src> UnsafeUnpin for HtmlReader<'src>
impl<'src> UnwindSafe for HtmlReader<'src>
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