Enum sauron::prelude::mt_dom::Node[]

pub enum Node<NS, TAG, ATT, VAL> where
    TAG: PartialEq<TAG> + Clone + Debug,
    NS: PartialEq<NS> + Clone + Debug,
    ATT: PartialEq<ATT> + Clone + Debug,
    VAL: PartialEq<VAL> + Clone + Debug
{ Element(Element<NS, TAG, ATT, VAL>), Text(Text), }
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, ATT, VAL>)

Element variant of a virtual node

Text(Text)

Text variant of a virtual node

Implementations

returns true if this a text node

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

returns the text content 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

create a Zipper for a Node

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

map the msg of callback of this element node

map the msg of callback of this element node

Return the callbacks present on this node

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

This method tests for !=.

render instance to a writable buffer with indention node_idx is for debugging purposes Read more

render the node to a writable buffer

no new_lines, no indents

render compressed html to string

render to string with nice indention

get the first attribute value with this attribute name

return the value of “key” attribute

return the boolean value of the “focus” attribute of this node

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

Performs the conversion.

Performs the conversion.

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)

recently added

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.