Skip to main content

Render

Trait Render 

Source
pub trait Render: Sized {
    // Required method
    fn template() -> Bytes;

    // Provided methods
    fn tasks(self) -> Option<Vec<Task>> { ... }
    fn response(id: &str, html: &str) -> Bytes { ... }
    fn final_chunk() -> Option<Bytes> { ... }
    fn render(self) -> impl Stream<Item = Bytes> { ... }
}
Expand description

Trait defining rendering logic.

A type implementing Render produces an initial template, optional async Tasks, and a final chunk if needed.

Required Methods§

Source

fn template() -> Bytes

Return the static HTML template for this renderer.

Provided Methods§

Source

fn tasks(self) -> Option<Vec<Task>>

Return the list of tasks associated with this renderer.

Defaults to None.

Source

fn response(id: &str, html: &str) -> Bytes

Build a <htms-chunk> wrapper from an ID and HTML fragment.

Source

fn final_chunk() -> Option<Bytes>

Optionally, return a final chunk to yield after all tasks complete. Mainly used for cleaning htms dirty tags and close the body/html tags.

Source

fn render(self) -> impl Stream<Item = Bytes>

Render the template plus task results as a stream of HTML chunks.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§