pub struct Template {
pub name: &'static str,
pub roots: &'static [TemplateNode],
pub node_paths: &'static [&'static [u8]],
pub attr_paths: &'static [&'static [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: &'static 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: &'static [TemplateNode]
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: &'static [&'static [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: &'static [&'static [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 Template
impl Template
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 Deserialize<'static> for Template
impl Deserialize<'static> for Template
§fn deserialize<__D>(
__deserializer: __D
) -> Result<Template, <__D as Deserializer<'static>>::Error>where
__D: Deserializer<'static>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Template, <__D as Deserializer<'static>>::Error>where
__D: Deserializer<'static>,
§impl Ord for Template
impl Ord for Template
§impl PartialOrd for Template
impl PartialOrd for Template
§fn partial_cmp(&self, other: &Template) -> Option<Ordering>
fn partial_cmp(&self, other: &Template) -> 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 Serialize for Template
impl Serialize for Template
§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 Copy for Template
impl Eq for Template
impl StructuralPartialEq for Template
Auto Trait Implementations§
impl Freeze for Template
impl RefUnwindSafe for Template
impl Send for Template
impl Sync for Template
impl Unpin for Template
impl UnwindSafe for Template
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<T> CallHasher for T
impl<T> CallHasher for T
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more