Skip to main content

VDom

Struct VDom 

Source
pub struct VDom<'a, const MAX_NODES: usize = 0, const MAX_STACK: usize = 0, const MAX_ROOTS: usize = 0, const MAX_IDS: usize = 0, const MAX_CLASSES: usize = 0, const MAX_SELECTOR_NODES: usize = 0> { /* private fields */ }
Expand description

VDom represents a Document Object Model

It is the result of parsing an HTML document. Internally it is only a wrapper around the Parser struct, in which all of the HTML tags are stored. Many functions of the public API take a reference to a Parser as a parameter to resolve NodeHandles to Nodes.

Implementations§

Source§

impl<'a, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize> VDom<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>

Source

pub fn parser( &self, ) -> &Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>

Returns a reference to the underlying parser

Source

pub fn parser_mut( &mut self, ) -> &mut Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>

Returns a mutable reference to the underlying parser

Source

pub fn get_element_by_id<'b, S>(&'b self, id: S) -> Option<NodeHandle>
where S: Into<Bytes<'a>>,

Finds an element by its id attribute.

Source

pub fn nodes(&self) -> &[Node<'a>]

Returns a slice of all the elements in the HTML document

The difference between children() and nodes() is that children only returns the immediate children of the root node, while nodes() returns all nodes, including nested tags.

§Order

The order of the returned nodes is the same as the order of the nodes in the HTML document.

Source

pub fn nodes_mut(&mut self) -> &mut [Node<'a>]

Returns a mutable slice of all the elements in the HTML document

The difference between children() and nodes() is that children only returns the immediate children of the root node, while nodes() returns all nodes, including nested tags.

Source

pub fn children(&self) -> &[NodeHandle]

Returns the topmost subnodes (“children”) of this DOM

Source

pub fn children_mut(&mut self) -> &mut [NodeHandle]

Returns a mutable reference to the topmost subnodes (“children”) of this DOM

Source

pub fn version(&self) -> Option<HTMLVersion>

Returns the HTML version. This is determined by the <!DOCTYPE> tag

Source

pub fn write_outer_html<W: Write>(&self, dest: &mut W) -> Result

Writes the contained markup of all root elements without allocating.

Source

pub fn query_selector<'b>( &'b self, selector: &'b str, ) -> Result<QuerySelectorIterator<'a, 'b, Self, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>, ParseError>

Tries to parse the query selector and returns an iterator over matching elements.

Trait Implementations§

Source§

impl<'a, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize> Debug for VDom<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize> From<Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>> for VDom<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>

Source§

fn from( parser: Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>, ) -> Self

Converts to this type from the input type.
Source§

impl<'a, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize> QueryIterable<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES> for VDom<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>

Source§

fn get<'b>( &'b self, parser: &'b Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>, index: usize, ) -> Option<(&'b Node<'a>, NodeHandle)>

Gets a node at a specific index
Source§

fn len( &self, _parser: &Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>, ) -> usize

Gets or computes the length (number of nodes)
Source§

fn start(&self) -> Option<InnerNodeHandle>

Gets the starting index

Auto Trait Implementations§

§

impl<'a, const MAX_NODES: usize = 0, const MAX_STACK: usize = 0, const MAX_ROOTS: usize = 0, const MAX_IDS: usize = 0, const MAX_CLASSES: usize = 0, const MAX_SELECTOR_NODES: usize = 0> !Send for VDom<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>

§

impl<'a, const MAX_NODES: usize = 0, const MAX_STACK: usize = 0, const MAX_ROOTS: usize = 0, const MAX_IDS: usize = 0, const MAX_CLASSES: usize = 0, const MAX_SELECTOR_NODES: usize = 0> !Sync for VDom<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>

§

impl<'a, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize> Freeze for VDom<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>

§

impl<'a, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize> RefUnwindSafe for VDom<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>

§

impl<'a, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize> Unpin for VDom<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>

§

impl<'a, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize> UnsafeUnpin for VDom<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>

§

impl<'a, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize> UnwindSafe for VDom<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>

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 = 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.