Enum sauron::prelude::mt_dom::Node [−]
pub enum Node<NS, TAG, ATT, VAL, EVENT> where
TAG: PartialEq<TAG> + Clone + Debug,
NS: PartialEq<NS> + Clone + Debug,
ATT: PartialEq<ATT> + Clone + Debug,
VAL: PartialEq<VAL> + Clone + Debug,
EVENT: PartialEq<EVENT> + Clone + Debug, { Element(Element<NS, TAG, ATT, VAL, EVENT>), 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>)
Element variant of a virtual node
Text(Text)
Text variant of a virtual node
Implementations
pub fn take_element(self) -> Option<Element<NS, TAG, ATT, VAL, EVENT>>
pub fn take_element(self) -> Option<Element<NS, TAG, ATT, VAL, EVENT>>
consume self and return the element if it is an element variant None if it is a text node
pub fn as_element_mut(
&mut self
) -> Option<&mut Element<NS, TAG, ATT, VAL, EVENT>>
pub fn as_element_mut(
&mut self
) -> Option<&mut Element<NS, TAG, ATT, VAL, EVENT>>
Get a mutable reference to the element, if this node is an element node
pub fn as_element_ref(&self) -> Option<&Element<NS, TAG, ATT, VAL, EVENT>>
pub fn as_element_ref(&self) -> Option<&Element<NS, TAG, ATT, VAL, EVENT>>
returns a reference to the element if this is an element node
pub fn add_children(
self,
children: Vec<Node<NS, TAG, ATT, VAL, EVENT>, Global>
) -> Node<NS, TAG, ATT, VAL, EVENT>
pub fn add_children(
self,
children: Vec<Node<NS, TAG, ATT, VAL, EVENT>, Global>
) -> Node<NS, TAG, ATT, VAL, EVENT>
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
pub fn add_children_ref_mut(
&mut self,
children: Vec<Node<NS, TAG, ATT, VAL, EVENT>, Global>
)
pub fn add_children_ref_mut(
&mut self,
children: Vec<Node<NS, TAG, ATT, VAL, EVENT>, Global>
)
add children but not consume self
pub fn add_attributes(
self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT>, Global>
) -> Node<NS, TAG, ATT, VAL, EVENT>
pub fn add_attributes(
self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT>, Global>
) -> Node<NS, TAG, ATT, VAL, EVENT>
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>, Global>
)
pub fn add_attributes_ref_mut(
&mut self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT>, Global>
)
add attributes using a mutable reference to self
pub fn get_attributes(&self) -> Option<&[Attribute<NS, ATT, VAL, EVENT>]>
pub fn get_attributes(&self) -> Option<&[Attribute<NS, ATT, VAL, EVENT>]>
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
pub fn get_children(&self) -> Option<&[Node<NS, TAG, ATT, VAL, EVENT>]>
pub fn get_children(&self) -> Option<&[Node<NS, TAG, ATT, VAL, EVENT>]>
return the children of this node if it is an element returns None if it is a text node
pub fn children_mut(&mut self) -> Option<&mut [Node<NS, TAG, ATT, VAL, EVENT>]>
pub fn children_mut(&mut self) -> Option<&mut [Node<NS, TAG, ATT, VAL, EVENT>]>
return the children of this node if it is an element returns None if it is a text node
pub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
recursive count the number of nodes under this tree
pub fn set_attributes_ref_mut(
&mut self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT>, Global>
)
pub fn set_attributes_ref_mut(
&mut self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT>, Global>
)
remove the existing attributes and set with the new value
pub fn merge_attributes(
self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT>, Global>
) -> Node<NS, TAG, ATT, VAL, EVENT>
pub fn merge_attributes(
self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT>, Global>
) -> Node<NS, TAG, ATT, VAL, EVENT>
merge to existing attributes if the attribute name already exist
Trait Implementations
impl<MSG> NodeMapMsg<MSG> for Node<&'static str, &'static str, &'static str, AttributeValue, Callback<Event, MSG>> where
MSG: 'static,
impl<MSG> NodeMapMsg<MSG> for Node<&'static str, &'static str, &'static str, AttributeValue, Callback<Event, MSG>> where
MSG: 'static,
map the msg of callback of this element node
pub fn map_callback<MSG2>(
self,
cb: Callback<MSG, MSG2>
) -> Node<&'static str, &'static str, &'static str, AttributeValue, Callback<Event, MSG2>> where
MSG2: 'static,
pub fn map_callback<MSG2>(
self,
cb: Callback<MSG, MSG2>
) -> Node<&'static str, &'static str, &'static str, AttributeValue, Callback<Event, MSG2>> where
MSG2: 'static,
map the msg of callback of this element node
impl<NS, TAG, ATT, VAL, EVENT> PartialEq<Node<NS, TAG, ATT, VAL, EVENT>> for Node<NS, TAG, ATT, VAL, EVENT> where
TAG: PartialEq<TAG> + Clone + Debug,
NS: PartialEq<NS> + Clone + Debug,
ATT: PartialEq<ATT> + Clone + Debug,
VAL: PartialEq<VAL> + Clone + Debug,
EVENT: PartialEq<EVENT> + Clone + Debug,
impl<NS, TAG, ATT, VAL, EVENT> PartialEq<Node<NS, TAG, ATT, VAL, EVENT>> for Node<NS, TAG, ATT, VAL, EVENT> where
TAG: PartialEq<TAG> + Clone + Debug,
NS: PartialEq<NS> + Clone + Debug,
ATT: PartialEq<ATT> + Clone + Debug,
VAL: PartialEq<VAL> + Clone + Debug,
EVENT: PartialEq<EVENT> + Clone + Debug,
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
get the first attribute value with this attribute name
return the boolean value of the “focus” attribute of this node
Auto Trait Implementations
impl<NS, TAG, ATT, VAL, EVENT> RefUnwindSafe for Node<NS, TAG, ATT, VAL, EVENT> where
ATT: RefUnwindSafe,
EVENT: RefUnwindSafe,
NS: RefUnwindSafe,
TAG: RefUnwindSafe,
VAL: RefUnwindSafe,
impl<NS, TAG, ATT, VAL, EVENT> Send for Node<NS, TAG, ATT, VAL, EVENT> where
ATT: Send,
EVENT: Send,
NS: Send,
TAG: Send,
VAL: Send,
impl<NS, TAG, ATT, VAL, EVENT> Sync for Node<NS, TAG, ATT, VAL, EVENT> where
ATT: Sync,
EVENT: Sync,
NS: Sync,
TAG: Sync,
VAL: Sync,
impl<NS, TAG, ATT, VAL, EVENT> Unpin for Node<NS, TAG, ATT, VAL, EVENT> where
ATT: Unpin,
EVENT: Unpin,
NS: Unpin,
TAG: Unpin,
VAL: Unpin,
impl<NS, TAG, ATT, VAL, EVENT> UnwindSafe for Node<NS, TAG, ATT, VAL, EVENT> where
ATT: UnwindSafe,
EVENT: UnwindSafe,
NS: UnwindSafe,
TAG: UnwindSafe,
VAL: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more