Skip to main content

dioxus_core/view/
text.rs

1//! The typed static text view: [`StaticTextBuilder`] and its marker trait
2//! [`StaticText`].
3
4use std::marker::PhantomData;
5
6use dioxus_core_template::TemplateRawTree;
7
8use super::{View, ViewTemplate};
9
10/// A marker for one static text node.
11pub trait StaticText {
12    /// Static text value.
13    const TEXT: &'static str;
14}
15
16/// A static text view.
17pub struct StaticTextBuilder<T>(#[doc(hidden)] pub PhantomData<T>);
18
19impl<T: StaticText> ViewTemplate for StaticTextBuilder<T> {
20    const TEMPLATE_TREE: &'static TemplateRawTree = &TemplateRawTree::StaticText(T::TEXT);
21}
22
23impl<T: StaticText> View for StaticTextBuilder<T> {}