Skip to main content

NodeKind

Enum NodeKind 

Source
pub enum NodeKind {
    Document,
    Element {
        name: String,
        namespace: Option<String>,
        attributes: Vec<Attribute>,
    },
    Text {
        content: String,
    },
    Comment {
        content: String,
    },
    ProcessingInstruction {
        target: String,
        data: String,
    },
    Doctype {
        name: Option<String>,
        public_identifier: Option<String>,
        system_identifier: Option<String>,
    },
    DocumentFragment,
}
Expand description

The kind of a document node and its associated data. Mostly covers what the HTML5 tokenizer can actually produce a token for (§13.2.5’s token kinds) — no CData/EntityRef variants, since the HTML5 tokenizer never emits those (character references and CDATA content both resolve straight to character tokens, see tokenizer::TokenKind’s doc comment). DocumentFragment is the one exception: not tokenizer-token-shaped at all, synthesized directly by tree construction (§13.2.6.1’s “create an element for a token” step, for template elements specifically).

Variants§

§

Document

The document node — there is exactly one per Document.

§

Element

An element node, e.g. <div class="x">.

Fields

§name: String
§namespace: Option<String>
§attributes: Vec<Attribute>
§

Text

A text node.

Fields

§content: String
§

Comment

A comment node.

Fields

§content: String
§

ProcessingInstruction

A processing instruction node, e.g. <?target data?>. Every insertion mode’s token dispatch has an explicit “processing instruction token” branch (verified against the raw spec text, not assumed) that inserts one of these — html-conform’s normalize() drops it afterwards, but tree-construction still puts it in the tree, so the node kind exists here too.

Fields

§target: String
§data: String
§

Doctype

A DOCUMENT TYPE node, e.g. <!DOCTYPE html>. Also dropped by html-conform::normalize(), but inserted into the tree by the “initial” insertion mode per spec, same reasoning as above.

Fields

§public_identifier: Option<String>
§system_identifier: Option<String>
§

DocumentFragment

A template element’s “template contents” — an inert fragment root that real content inserted “inside” a template element actually lands in, per §13.2.6.1’s “appropriate place for inserting a node”. Modeled here as the template element’s sole real tree child (created alongside it, see tree_builder.rs::create_element_for_token), since Document has no separate out-of-tree fragment concept — matching how html5lib-tests’ own #document dump format represents it (a synthetic content line, with the real children nested one level below that).

Trait Implementations§

Source§

impl Clone for NodeKind

Source§

fn clone(&self) -> NodeKind

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeKind

Source§

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

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

impl Eq for NodeKind

Source§

impl PartialEq for NodeKind

Source§

fn eq(&self, other: &NodeKind) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for NodeKind

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.