Skip to main content

HtmlReader

Struct HtmlReader 

Source
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>

Source

pub fn new(input: &'src str) -> HtmlReader<'src>

Source

pub fn with_opts(input: &'src str, opts: HtmlParseOptions) -> HtmlReader<'src>

Source

pub fn next(&mut self) -> Result<HtmlEvent<'_>, XmlError>

Pull the next event. Returns Eof when input is exhausted.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.