Enum mt_dom::Node [−][src]
pub enum Node<NS, TAG, ATT, VAL, EVENT, MSG> { Element(Element<NS, TAG, ATT, VAL, EVENT, MSG>), 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, EVENT, MSG>)
Element variant of a virtual node
Text(Text)
Text variant of a virtual 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
pub fn add_attributes_ref_mut(
&mut self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)
pub fn add_attributes_ref_mut(
&mut self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)
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 children of this node if it is an element returns None if it is a text node
recursive count the number of nodes under this tree
Note: using the #[derive(PartialEq)] needs EVENT and MSG to also be PartialEq.
The reason this is manually implemented is, so that EVENT and MSG doesn’t need to be PartialEq as it is part of the Callback objects and are not compared
pub fn set_attributes_ref_mut(
&mut self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)
pub fn set_attributes_ref_mut(
&mut self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)
remove the existing attributes and set with the new value
merge to existing attributes if the attribute name already exist
map the msg of callback of this element node
pub fn map_callback<MSG2>(
self,
cb: Callback<MSG, MSG2>
) -> Node<NS, TAG, ATT, VAL, EVENT, MSG2> where
MSG2: 'static,
pub fn map_callback<MSG2>(
self,
cb: Callback<MSG, MSG2>
) -> Node<NS, TAG, ATT, VAL, EVENT, MSG2> where
MSG2: 'static,
map the msg of callback of this element node
Trait Implementations
Note: using the #[derive(Debug)] needs EVENT and MSG to also be Debug
The reason this is manually implemented is, so that EVENT and MSG doesn’t need to be Debug as it is part of the Callback objects and are not shown.
impl<NS, TAG, ATT, VAL, EVENT, MSG> StructuralPartialEq for Node<NS, TAG, ATT, VAL, EVENT, MSG>
Auto Trait Implementations
impl<NS, TAG, ATT, VAL, EVENT, MSG> !RefUnwindSafe for Node<NS, TAG, ATT, VAL, EVENT, MSG>
impl<NS, TAG, ATT, VAL, EVENT, MSG> Unpin for Node<NS, TAG, ATT, VAL, EVENT, MSG> where
ATT: Unpin,
NS: Unpin,
TAG: Unpin,
VAL: Unpin,
impl<NS, TAG, ATT, VAL, EVENT, MSG> !UnwindSafe for Node<NS, TAG, ATT, VAL, EVENT, MSG>
Blanket Implementations
Mutably borrows from an owned value. Read more