Struct dioxus_core::prelude::Template
source · pub struct Template<'a> {
pub name: &'a str,
pub roots: &'a [TemplateNode<'a>],
pub node_paths: &'a [&'a [u8]],
pub attr_paths: &'a [&'a [u8]],
}
Expand description
A static layout of a UI tree that describes a set of dynamic and static nodes.
This is the core innovation in Dioxus. Most UIs are made of static nodes, yet participate in diffing like any dynamic node. This struct can be created at compile time. It promises that its name is unique, allow Dioxus to use its static description of the UI to skip immediately to the dynamic nodes during diffing.
For this to work properly, the Template::name
must be unique across your entire project. This can be done via variety of
ways, with the suggested approach being the unique code location (file, line, col, etc).
Fields§
§name: &'a str
The name of the template. This must be unique across your entire program for template diffing to work properly
If two templates have the same name, it’s likely that Dioxus will panic when diffing.
roots: &'a [TemplateNode<'a>]
The list of template nodes that make up the template
Unlike react, calls to rsx!
can have multiple roots. This list supports that paradigm.
node_paths: &'a [&'a [u8]]
The paths of each node relative to the root of the template.
These will be one segment shorter than the path sent to the renderer since those paths are relative to the
topmost element, not the roots
field.
attr_paths: &'a [&'a [u8]]
The paths of each dynamic attribute relative to the root of the template
These will be one segment shorter than the path sent to the renderer since those paths are relative to the
topmost element, not the roots
field.
Implementations§
Trait Implementations§
source§impl<'de: 'a, 'a> Deserialize<'de> for Template<'a>
impl<'de: 'a, 'a> Deserialize<'de> for Template<'a>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl<'a> Ord for Template<'a>
impl<'a> Ord for Template<'a>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl<'a> PartialEq<Template<'a>> for Template<'a>
impl<'a> PartialEq<Template<'a>> for Template<'a>
source§impl<'a> PartialOrd<Template<'a>> for Template<'a>
impl<'a> PartialOrd<Template<'a>> for Template<'a>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more