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§
§impl<'a> Template<'a>
impl<'a> Template<'a>
pub fn is_completely_dynamic(&self) -> bool
pub fn is_completely_dynamic(&self) -> bool
Is this template worth caching at all, since it’s completely runtime?
There’s no point in saving templates that are completely dynamic, since they’ll be recreated every time anyway.
Trait Implementations§
§impl<'de, 'a> Deserialize<'de> for Template<'a>where
'de: 'a,
impl<'de, 'a> Deserialize<'de> for Template<'a>where 'de: 'a,
§fn deserialize<__D>(
__deserializer: __D
) -> Result<Template<'a>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>( __deserializer: __D ) -> Result<Template<'a>, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,
§impl<'a> Ord for Template<'a>
impl<'a> Ord for Template<'a>
§impl<'a> PartialEq<Template<'a>> for Template<'a>
impl<'a> PartialEq<Template<'a>> for Template<'a>
§impl<'a> PartialOrd<Template<'a>> for Template<'a>
impl<'a> PartialOrd<Template<'a>> for Template<'a>
§fn partial_cmp(&self, other: &Template<'a>) -> Option<Ordering>
fn partial_cmp(&self, other: &Template<'a>) -> Option<Ordering>
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§impl<'a> Serialize for Template<'a>
impl<'a> Serialize for Template<'a>
§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where __S: Serializer,
impl<'a> Copy for Template<'a>
impl<'a> Eq for Template<'a>
impl<'a> StructuralEq for Template<'a>
impl<'a> StructuralPartialEq for Template<'a>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Template<'a>
impl<'a> Send for Template<'a>
impl<'a> Sync for Template<'a>
impl<'a> Unpin for Template<'a>
impl<'a> UnwindSafe for Template<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.