[−][src]Trait dodrio::Render
A trait for any component that can be rendered to HTML.
Takes a shared reference to self
and generates the virtual DOM that
represents its rendered HTML.
Bump
Allocation
Render
implementations can use the provided Bump
for very fast
allocation for anything that needs to be allocated during rendering.
The 'a: 'bump
Lifetime Bound
The 'a: 'bump
bounds enforce that self
outlives the given bump
allocator. This means that if self
contains a string, the string does not
need to be copied into the output Node
and can be used by reference
instead (i.e. it prevents accidentally using the string after its been
freed). The 'a: 'bump
bound also enables abstractions like
dodrio::Cached
that can re-use cached Node
s across render
s without
copying them.
Example
use dodrio::{bumpalo::Bump, Node, Render}; pub struct MyComponent; impl Render for MyComponent { fn render<'a, 'bump>(&'a self, bump: &'bump Bump) -> Node<'bump> where 'a: 'bump { use dodrio::builder::*; p(bump) .children([ text("This is "), strong(bump).children([text("my component")]).finish(), text(" rendered!"), ]) .finish() } }
Required methods
fn render<'a, 'bump>(&'a self, bump: &'bump Bump) -> Node<'bump> where
'a: 'bump,
'a: 'bump,
Render self
as a virtual DOM. Use the given Bump
for temporary
allocations.
Implementations on Foreign Types
impl<'r, R> Render for &'r R where
R: Render,
[src]
R: Render,
impl<R> Render for Rc<R> where
R: Render,
[src]
Loading content...
R: Render,