[−]Enum sauron::prelude::mt_dom::Node
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>>
&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>>
) -> Node<NS, TAG, ATT, VAL, EVENT, MSG>
self,
children: Vec<Node<NS, TAG, ATT, VAL, EVENT, MSG>>
) -> 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>>
)
&mut self,
children: Vec<Node<NS, TAG, ATT, VAL, EVENT, MSG>>
)
add children but not consume self
pub fn add_attributes(
self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
) -> Node<NS, TAG, ATT, VAL, EVENT, MSG>
self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
) -> 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>>
)
&mut self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)
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>]>
&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>,
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>>
)
&mut self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
)
remove the existing attributes and set with the new value
pub fn merge_attributes(
self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
) -> Node<NS, TAG, ATT, VAL, EVENT, MSG>
self,
attributes: Vec<Attribute<NS, ATT, VAL, EVENT, MSG>>
) -> 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>>
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
EVENT: 'static,
MSG: 'static,
EVENT: 'static,
MSG: '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,
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,
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
ATT: Clone,
NS: Clone,
TAG: Clone,
VAL: Clone,
ATT: Clone,
NS: Clone,
TAG: Clone,
VAL: Clone,
pub fn clone(&self) -> Node<NS, TAG, ATT, VAL, EVENT, MSG>
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<NS, TAG, ATT, VAL, EVENT, MSG> Debug for Node<NS, TAG, ATT, VAL, EVENT, MSG> where
ATT: Debug,
NS: Debug,
TAG: Debug,
VAL: Debug,
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> PartialEq<Node<NS, TAG, ATT, VAL, EVENT, MSG>> for Node<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>,
ATT: PartialEq<ATT>,
EVENT: PartialEq<EVENT>,
MSG: PartialEq<MSG>,
NS: PartialEq<NS>,
TAG: PartialEq<TAG>,
VAL: PartialEq<VAL>,
pub fn eq(&self, other: &Node<NS, TAG, ATT, VAL, EVENT, MSG>) -> bool
pub fn ne(&self, other: &Node<NS, TAG, ATT, VAL, EVENT, MSG>) -> bool
impl<MSG> Render for Node<&'static str, &'static str, &'static str, AttributeValue, Event, MSG>
[src]
pub fn render_with_indent(
&self,
buffer: &mut dyn Write,
indent: usize,
node_idx: &mut Option<usize>,
compressed: bool
) -> Result<(), Error>
[src]
&self,
buffer: &mut dyn Write,
indent: usize,
node_idx: &mut Option<usize>,
compressed: bool
) -> Result<(), Error>
fn render(&self, buffer: &mut dyn Write) -> Result<(), Error>
[src]
fn render_compressed(&self, buffer: &mut dyn Write) -> Result<(), Error>
[src]
fn render_to_string(&self) -> String
[src]
impl<MSG> Special for Node<&'static str, &'static str, &'static str, AttributeValue, Event, MSG>
[src]
pub fn get_value(&'a self, att_name: &'static str) -> Option<&'a Value>
[src]
fn get_key(&self) -> Option<&Value>
[src]
fn is_focused(&self) -> bool
[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>
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,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow(&self) -> &TⓘNotable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?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;
[src]
Notable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?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;
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut TⓘNotable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?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;
[src]
Notable traits for &'_ mut W
impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, R> Read for &'_ mut R where
R: Read + ?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;
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,