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

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

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>

pub fn is_text(&self) -> bool

returns true if this a text node

pub fn take_element(self) -> Option<Element<NS, TAG, ATT, VAL, EVENT, MSG>>

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>>

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>>

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>, Global>
) -> Node<NS, TAG, ATT, VAL, EVENT, MSG>

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>, Global>
)

add children but not consume self

pub fn add_attributes(
    self,
    attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>, Global>
) -> Node<NS, TAG, ATT, VAL, EVENT, MSG>

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>, Global>
)

add attributes using a mutable reference to self

pub fn get_attributes(&self) -> Option<&[Attribute<NS, ATT, VAL, EVENT, MSG>]>

get the attributes of this node returns None if it is a text node

pub fn tag(&self) -> Option<&TAG>

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>

returns the text content if it is a text node

pub fn get_children(&self) -> Option<&[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 children_mut(
    &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

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<ATT>, 

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>, Global>
)

remove the existing attributes and set with the new value

pub fn merge_attributes(
    self,
    attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>, Global>
) -> Node<NS, TAG, ATT, VAL, EVENT, MSG>

merge to existing attributes if the attribute name already exist

pub fn get_attribute_value(&self, name: &ATT) -> Option<Vec<&VAL, Global>>

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
    MSG: 'static,
    EVENT: '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, 

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, 

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
    TAG: Clone,
    NS: Clone,
    ATT: Clone,
    VAL: Clone

impl<NS, TAG, ATT, VAL, EVENT, MSG> Debug for Node<NS, TAG, ATT, VAL, EVENT, MSG> where
    TAG: Debug,
    NS: 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, TAG, ATT, VAL, EVENT, MSG> PartialEq<Node<NS, TAG, ATT, VAL, EVENT, MSG>> for Node<NS, TAG, ATT, VAL, EVENT, MSG> where
    MSG: PartialEq<MSG>,
    TAG: PartialEq<TAG>,
    NS: PartialEq<NS>,
    ATT: PartialEq<ATT>,
    VAL: PartialEq<VAL>,
    EVENT: PartialEq<EVENT>, 

impl<MSG> Render for Node<&'static str, &'static str, &'static str, AttributeValue, Event, MSG>[src]

impl<MSG> Special for Node<&'static str, &'static str, &'static str, AttributeValue, Event, MSG>[src]

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>[src]

impl<NS, TAG, ATT, VAL, EVENT, MSG> !Send for Node<NS, TAG, ATT, VAL, EVENT, MSG>[src]

impl<NS, TAG, ATT, VAL, EVENT, MSG> !Sync for Node<NS, TAG, ATT, VAL, EVENT, MSG>[src]

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
[src]

impl<NS, TAG, ATT, VAL, EVENT, MSG> !UnwindSafe for Node<NS, TAG, ATT, VAL, EVENT, MSG>[src]

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.