[][src]Enum mt_dom::Node

pub enum Node<NS, TAG, ATT, VAL, EVENT, MSG> {
    Element(Element<NS, TAG, ATT, VAL, EVENT, MSG>),
    Text(String),
}

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(String)

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]

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]

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_attributes(
    self,
    attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
) -> Self
[src]

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]

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

impl<NS, TAG, ATT, VAL, EVENT, MSG> Node<NS, TAG, ATT, VAL, EVENT, MSG> where
    ATT: PartialEq
[src]

pub fn set_attributes_ref_mut(
    &mut self,
    attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)
[src]

remove the existing attributes and set with the new value

impl<NS, TAG, ATT, VAL, EVENT, MSG> Node<NS, TAG, ATT, VAL, EVENT, MSG> where
    EVENT: 'static,
    MSG: 'static, 
[src]

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]

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]

map the msg of callback of this element node

Trait Implementations

impl<NS: Clone, TAG: Clone, ATT: Clone, VAL: Clone, EVENT: Clone, MSG: Clone> Clone for Node<NS, TAG, ATT, VAL, EVENT, MSG>[src]

impl<NS: Debug, TAG: Debug, ATT: Debug, VAL: Debug, EVENT: Debug, MSG: Debug> Debug for Node<NS, TAG, ATT, VAL, EVENT, MSG>[src]

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]

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

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.