pub enum Node<NS, TAG, LEAF, ATT, VAL> where
    NS: PartialEq + Clone + Debug,
    TAG: PartialEq + Debug,
    LEAF: PartialEq + Clone + Debug,
    ATT: PartialEq + Clone + Debug,
    VAL: PartialEq + Clone + Debug
{ Element(Element<NS, TAG, LEAF, ATT, VAL>), Leaf(LEAF), }
Expand description

represents a node in a virtual dom A node could be an element which can contain one or more children of nodes. A node could also be just a text node which contains a string

Much of the types are Generics

NS - is the type for the namespace, this will be &’static str when used in html based virtual dom implementation TAG - is the type for the element tag, this will be &’static str when used in html based virtual dom impmenentation ATT - is the type for the attribute name, this will be &’static str when used in html based virtual dom implementation VAL - is the type for the value of the attribute, this will be String, f64, or just another generics that suits the implementing library which used mt-dom for just dom-diffing purposes

Variants

Element(Element<NS, TAG, LEAF, ATT, VAL>)

Element variant of a virtual node

Leaf(LEAF)

A Leaf node

Implementations

consume self and return the element if it is an element variant None if it is a text node

Get a mutable reference to the element, if this node is an element node

returns a reference to the element if this is an element node

Consume a mutable self and add a children to this node it if is an element will have no effect if it is a text node. This is used in building the nodes in a builder pattern

add children but not consume self

add attributes to the node and returns itself this is used in view building

add attributes using a mutable reference to self

get the attributes of this node returns None if it is a text node

returns the tag of this node if it is an element otherwise None if it is a text node

return the children of this node if it is an element returns None if it is a text node

Return the count of the children of this node

return the children of this node if it is an element returns None if it is a text node

Removes an child node from this element and returns it.

The removed child is replaced by the last child of the element’s children.

Panics

Panics if this is a text node

Swaps the 2 child node in this element

Arguments
  • a - The index of the first child node
  • b - The index of the second child node
Panics

Panics if both a and b are out of bounds Panics if this is a text node

Returns the total number of nodes on this node tree, that is counting the direct and indirect child nodes of this node.

only count the descendant node

remove the existing attributes and set with the new value

merge to existing attributes if the attribute name already exist

returh the attribute values of this node which match the attribute name name

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.