[]Struct sauron::prelude::mt_dom::Element

pub struct Element<NS, TAG, ATT, VAL, EVENT, MSG> {
    pub namespace: Option<NS>,
    pub tag: TAG,
    pub attrs: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>,
    pub children: Vec<Node<NS, TAG, ATT, VAL, EVENT, MSG>>,
}

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.

Fields

namespace: Option<NS>

namespace of this element, svg elements requires namespace to render correcly in the browser

tag: TAG

the element tag, such as div, a, button

attrs: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>

attributes for this element

children: Vec<Node<NS, TAG, ATT, VAL, EVENT, MSG>>

children elements of this element

Implementations

impl<NS, TAG, ATT, VAL, EVENT, MSG> Element<NS, TAG, ATT, VAL, EVENT, MSG>

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

create a new instance of an element

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

add attributes to this element

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

add children virtual node to this element

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

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]

returns a refernce to the children of this node

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

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]

returns a mutable reference to the children of this node

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

Notable traits for Vec<u8>

impl Write for Vec<u8>

consume self and return the children

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

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]

return a reference to the attribute of this element

pub fn take_attributes(self) -> Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>

Notable traits for Vec<u8>

impl Write for Vec<u8>

consume self and return the attributes

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

return the namespace of this element

pub fn tag(&self) -> &TAG

Notable traits for &'_ mut R

impl<'_, R> Read for &'_ mut R where
    R: Read + ?Sized
impl<'_, W> Write for &'_ mut W where
    W: Write + ?Sized
impl<'_, F> Future for &'_ mut F where
    F: Unpin + Future + ?Sized
type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
    I: Iterator + ?Sized
type Item = <I as Iterator>::Item;

return the tag of this element

pub fn take_tag(self) -> TAG

consume self and return the tag of this element

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

change the tag of this element

impl<NS, TAG, ATT, VAL, EVENT, MSG> Element<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 remove_attribute(&mut self, key: &ATT)

remove the attributes with this key

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

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

pub fn merge_attributes(
    &mut self,
    new_attrs: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)

merge to existing attributes if it exist

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

return all the attribute values which the name &ATT

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

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

map_callback the return of the callback from MSG to MSG2

Trait Implementations

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

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

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

impl<MSG> Render for Element<&'static str, &'static str, &'static str, AttributeValue, 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.