Skip to main content

Document

Struct Document 

Source
pub struct Document<'a> { /* private fields */ }
Expand description

An immutable source-order document with borrowed strings.

Each emitted start tag creates an element. An end tag closes the innermost open element with that name and its descendants; unmatched end tags are ignored. HTML void elements close immediately. The self-closing flag on other HTML elements is ignored. Remaining elements close at EOF. No elements are implied, relocated, or cloned: this is not the HTML browser tree-building algorithm.

Construction, traversal, and destruction use flat storage without recursion.

Implementations§

Source§

impl<'a> Document<'a>

Source

pub fn parse(source: &'a str) -> Result<Self, Error>

Parse a document with the default resource limits.

Source

pub fn parse_with_limits(source: &'a str, limits: Limits) -> Result<Self, Error>

Parse a document with caller-selected resource limits.

Malformed HTML follows tokenizer recovery and lexical scope rules. Only resource-limit violations return errors; no partial document is returned.

Source

pub fn elements(&self) -> impl Iterator<Item = Element<'_, 'a>>

Iterate over every element in source order.

Auto Trait Implementations§

§

impl<'a> Freeze for Document<'a>

§

impl<'a> RefUnwindSafe for Document<'a>

§

impl<'a> Send for Document<'a>

§

impl<'a> Sync for Document<'a>

§

impl<'a> Unpin for Document<'a>

§

impl<'a> UnsafeUnpin for Document<'a>

§

impl<'a> UnwindSafe for Document<'a>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.