[][src]Enum sauron_vdom::Node

pub enum Node<T, ATT, EVENT, MSG> where
    MSG: 'static,
    EVENT: 'static,
    ATT: Clone
{ Element(Element<T, ATT, EVENT, MSG>), Text(Text), }

This is the core data structure of the library. Any tree can be represented by Node. The T is generic instead of just using plain &'static str in order for this library to be used not only in html based widget but can also be used to represent native GUI widgets in various platforms.

Note: Clone is necessary for the aesthetics in the construction of node through series of function calls. Without Clone, the user code would look like these:

This example is not tested
    div(&[class("some-class"), &[text("Some text")])

as compared to

This example is not tested
    div([class("some-class"), [text("some text)])

Cloning is only done once, and happens when constructing the views into a node tree. Cloning also allows flexibility such as adding more children into an existing node/element.

Variants

Element(Element<T, ATT, EVENT, MSG>)

Element variant of a virtual node

Text(Text)

Text variant of a virtual node

Implementations

impl<T, ATT, EVENT, MSG> Node<T, ATT, EVENT, MSG> where
    EVENT: 'static,
    MSG: 'static,
    ATT: PartialEq + Ord + ToString + Clone
[src]

pub fn map_msg<F, MSG2>(self, func: F) -> Node<T, ATT, EVENT, MSG2> where
    F: Fn(MSG) -> MSG2 + 'static,
    MSG2: 'static, 
[src]

map the msg of callback of this element node

pub fn take_element(self) -> Option<Element<T, ATT, EVENT, MSG>>[src]

consume the element

pub fn as_element_mut(&mut self) -> Option<&mut Element<T, ATT, 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<T, ATT, EVENT, MSG>>[src]

returns a reference to the element if this is an element node

pub fn add_children(self, children: Vec<Node<T, ATT, EVENT, MSG>>) -> Self[src]

Append children to this element

pub fn add_attributes(self, attributes: Vec<Attribute<ATT, 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<ATT, EVENT, MSG>>
)
[src]

add attributes using a mutable reference to self

pub fn get_attributes(&self) -> Vec<Attribute<ATT, EVENT, MSG>>[src]

get the attributes of this node

pub fn tag(&self) -> Option<&T>[src]

returns the tag of this node if it is an element

pub fn text(&self) -> Option<&str>[src]

returns the text content if it is a text node

pub fn eldest_child_text(&self) -> Option<&str>[src]

returns the text if this node has only one child and is a text. includes: h1, h2..h6, p,

pub fn get_children(&self) -> Option<&[Node<T, ATT, EVENT, MSG>]>[src]

return the children of this node if it is an element

Trait Implementations

impl<T: Clone, ATT: Clone, EVENT: Clone, MSG: Clone> Clone for Node<T, ATT, EVENT, MSG> where
    MSG: 'static,
    EVENT: 'static,
    ATT: Clone
[src]

impl<T: Debug, ATT: Debug, EVENT: Debug, MSG: Debug> Debug for Node<T, ATT, EVENT, MSG> where
    MSG: 'static,
    EVENT: 'static,
    ATT: Clone
[src]

impl<T, ATT, EVENT, MSG> Display for Node<T, ATT, EVENT, MSG> where
    T: ToString,
    EVENT: 'static,
    MSG: 'static,
    ATT: PartialEq + Ord + ToString + Clone
[src]

impl<T, ATT, EVENT, MSG> From<Element<T, ATT, EVENT, MSG>> for Node<T, ATT, EVENT, MSG> where
    ATT: Clone
[src]

impl<T: PartialEq, ATT: PartialEq, EVENT: PartialEq, MSG: PartialEq> PartialEq<Node<T, ATT, EVENT, MSG>> for Node<T, ATT, EVENT, MSG> where
    MSG: 'static,
    EVENT: 'static,
    ATT: Clone
[src]

impl<T, ATT, EVENT, MSG> StructuralPartialEq for Node<T, ATT, EVENT, MSG> where
    MSG: 'static,
    EVENT: 'static,
    ATT: Clone
[src]

Auto Trait Implementations

impl<T, ATT, EVENT, MSG> !RefUnwindSafe for Node<T, ATT, EVENT, MSG>

impl<T, ATT, EVENT, MSG> !Send for Node<T, ATT, EVENT, MSG>

impl<T, ATT, EVENT, MSG> !Sync for Node<T, ATT, EVENT, MSG>

impl<T, ATT, EVENT, MSG> Unpin for Node<T, ATT, EVENT, MSG> where
    ATT: Unpin,
    T: Unpin

impl<T, ATT, EVENT, MSG> !UnwindSafe for Node<T, ATT, 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> ToString for T where
    T: Display + ?Sized
[src]

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.