[−][src]Enum mt_dom::Node
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
impl<NS, TAG, ATT, VAL, EVENT, MSG> Node<NS, TAG, ATT, VAL, EVENT, MSG>
[src]
pub fn is_text(&self) -> bool
[src]
returns true if this a text node
pub fn take_element(self) -> Option<Element<NS, TAG, ATT, VAL, EVENT, MSG>>
[src]
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, MSG>>
[src]
&mut self
) -> Option<&mut Element<NS, TAG, ATT, VAL, EVENT, MSG>>
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, MSG>>
[src]
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, MSG>>
) -> Self
[src]
self,
children: Vec<Node<NS, TAG, ATT, VAL, EVENT, MSG>>
) -> Self
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, MSG>>
)
[src]
&mut self,
children: Vec<Node<NS, TAG, ATT, VAL, EVENT, MSG>>
)
add children but not consume self
pub fn add_attributes(
self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
) -> Self
[src]
self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
) -> 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>>
)
[src]
&mut self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)
add attributes using a mutable reference to self
pub fn get_attributes(&self) -> Option<&[Attribute<NS, ATT, VAL, EVENT, MSG>]>
[src]
get the attributes of this node returns None if it is a text node
pub fn tag(&self) -> Option<&TAG>
[src]
returns the tag of this node if it is an element otherwise None if it is a text node
pub fn text(&self) -> Option<&str>
[src]
returns the text content if it is a text node
pub fn get_children(&self) -> Option<&[Node<NS, TAG, ATT, VAL, EVENT, MSG>]>
[src]
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, MSG>]>
[src]
&mut self
) -> Option<&mut [Node<NS, TAG, ATT, VAL, EVENT, MSG>]>
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
[src]
recursive count the number of nodes under this tree
impl<NS, TAG, ATT, VAL, EVENT, MSG> Node<NS, TAG, ATT, VAL, EVENT, MSG> where
ATT: PartialEq,
[src]
ATT: PartialEq,
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>>
)
[src]
&mut self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)
remove the existing attributes and set with the new value
pub fn merge_attributes(
self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
) -> Self
[src]
self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
) -> Self
merge to existing attributes if the attribute name already exist
pub fn get_attribute_value(&self, name: &ATT) -> Option<Vec<&VAL>>
[src]
returh the attribute values of this node which match the attribute name name
impl<NS, TAG, ATT, VAL, EVENT, MSG> Node<NS, TAG, ATT, VAL, EVENT, MSG> where
EVENT: 'static,
MSG: 'static,
[src]
EVENT: 'static,
MSG: 'static,
pub fn map_msg<F, MSG2>(self, func: F) -> Node<NS, TAG, ATT, VAL, EVENT, MSG2> where
F: Fn(MSG) -> MSG2 + 'static,
MSG2: 'static,
[src]
F: Fn(MSG) -> MSG2 + 'static,
MSG2: 'static,
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,
[src]
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
impl<NS, TAG, ATT, VAL, EVENT, MSG> Clone for Node<NS, TAG, ATT, VAL, EVENT, MSG> where
NS: Clone,
TAG: Clone,
ATT: Clone,
VAL: Clone,
[src]
NS: Clone,
TAG: Clone,
ATT: Clone,
VAL: Clone,
pub fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<NS, TAG, ATT, VAL, EVENT, MSG> Debug for Node<NS, TAG, ATT, VAL, EVENT, MSG> where
NS: Debug,
TAG: Debug,
ATT: Debug,
VAL: Debug,
[src]
NS: Debug,
TAG: Debug,
ATT: Debug,
VAL: Debug,
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: PartialEq, TAG: PartialEq, ATT: PartialEq, VAL: PartialEq, EVENT: PartialEq, MSG: PartialEq> PartialEq<Node<NS, TAG, ATT, VAL, EVENT, MSG>> for Node<NS, TAG, ATT, VAL, EVENT, MSG>
[src]
pub fn eq(&self, other: &Node<NS, TAG, ATT, VAL, EVENT, MSG>) -> bool
[src]
pub fn ne(&self, other: &Node<NS, TAG, ATT, VAL, EVENT, MSG>) -> bool
[src]
impl<NS, TAG, ATT, VAL, EVENT, MSG> StructuralPartialEq for Node<NS, TAG, ATT, VAL, EVENT, MSG>
[src]
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> !Send for Node<NS, TAG, ATT, VAL, EVENT, MSG>
impl<NS, TAG, ATT, VAL, EVENT, MSG> !Sync 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,
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,