[][src]Struct mt_dom::Element

pub struct Element<NS, TAG, ATT, VAL, EVENT, MSG> { /* fields omitted */ }

Represents an element of the virtual node An element has a generic tag, this tag could be a static str tag, such as usage in html dom. Example of which are div, a, input, img, etc.

Tag is a generic type, which can represent a different DOM tree other than the html dom such as widgets in native platform such as gtk, example of which are Hpane, Vbox, Image,

An element can have an optional namespace, such in the case for html dom where namespace like HTML and SVG, which needs to specified in order to create the DOM element to work on the browser.

The namespace is also needed in attributes where namespace are necessary such as xlink:href where the namespace xlink is needed in order for the linked element in an svg image to work.

Implementations

impl<NS, TAG, ATT, VAL, EVENT, MSG> Element<NS, TAG, ATT, VAL, EVENT, MSG>[src]

pub fn new(
    namespace: Option<NS>,
    tag: TAG,
    attrs: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>,
    children: Vec<Node<NS, TAG, ATT, VAL, EVENT, MSG>>
) -> Self
[src]

create a new instance of an element

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

add attributes to this element

pub fn add_children(
    &mut self,
    children: Vec<Node<NS, TAG, ATT, VAL, EVENT, MSG>>
)
[src]

add children virtual node to this element

pub fn get_children(&self) -> &[Node<NS, TAG, ATT, VAL, EVENT, MSG>][src]

returns a refernce to the children of this node

pub fn children_mut(&mut self) -> &mut [Node<NS, TAG, ATT, VAL, EVENT, MSG>][src]

returns a mutable refernce to the children of this node

pub fn take_children(self) -> Vec<Node<NS, TAG, ATT, VAL, EVENT, MSG>>[src]

consume self and return the children

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

return a reference to the attribute of this element

pub fn namespace(&self) -> Option<&NS>[src]

return the namespace of this element

pub fn tag(&self) -> &TAG[src]

return the tag of this element

pub fn set_tag(&mut self, tag: TAG)[src]

change the tag of this element

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

pub fn remove_attribute(&mut self, key: &ATT)[src]

remove the attributes with this key

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

remove the existing values of this attribute and add the new values

pub fn get_attribute_values(&self, key: &ATT) -> Vec<&AttValue<VAL, EVENT, MSG>>[src]

return the values of the attributes that matches the given attribute name

pub fn get_attribute_key_values(
    &self
) -> Vec<(&ATT, Vec<&AttValue<VAL, EVENT, MSG>>)>
[src]

return the aggregated values of attributes that has the same name in this element

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

pub fn map_callback<MSG2>(
    self,
    cb: Callback<MSG, MSG2>
) -> Element<NS, TAG, ATT, VAL, EVENT, MSG2> where
    MSG2: 'static, 
[src]

map_callback the return of the callback from MSG to MSG2

Trait Implementations

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

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

impl<NS: Default, TAG: Default, ATT: Default, VAL: Default, EVENT: Default, MSG: Default> Default for Element<NS, TAG, ATT, VAL, EVENT, MSG>[src]

impl<NS: PartialEq, TAG: PartialEq, ATT: PartialEq, VAL: PartialEq, EVENT: PartialEq, MSG: PartialEq> PartialEq<Element<NS, TAG, ATT, VAL, EVENT, MSG>> for Element<NS, TAG, ATT, VAL, EVENT, MSG>[src]

impl<NS, TAG, ATT, VAL, EVENT, MSG> StructuralPartialEq for Element<NS, TAG, ATT, VAL, EVENT, MSG>[src]

Auto Trait Implementations

impl<NS, TAG, ATT, VAL, EVENT, MSG> !RefUnwindSafe for Element<NS, TAG, ATT, VAL, EVENT, MSG>

impl<NS, TAG, ATT, VAL, EVENT, MSG> !Send for Element<NS, TAG, ATT, VAL, EVENT, MSG>

impl<NS, TAG, ATT, VAL, EVENT, MSG> !Sync for Element<NS, TAG, ATT, VAL, EVENT, MSG>

impl<NS, TAG, ATT, VAL, EVENT, MSG> Unpin for Element<NS, TAG, ATT, VAL, EVENT, MSG> where
    ATT: Unpin,
    NS: Unpin,
    TAG: Unpin,
    VAL: Unpin

impl<NS, TAG, ATT, VAL, EVENT, MSG> !UnwindSafe for Element<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.