pub trait Template: Display {
    const EXTENSION: Option<&'static str>;
    const SIZE_HINT: usize;
    const MIME_TYPE: &'static str;

    // Required method
    fn render_into(&self, writer: &mut impl Write) -> Result<(), Error>;

    // Provided methods
    fn render(&self) -> Result<String, Error> { ... }
    fn write_into(&self, writer: &mut impl Write) -> Result<(), Error> { ... }
}
Expand description

Main Template trait; implementations are generally derived

If you need an object-safe template, use DynTemplate.

Required Associated Constants§

source

const EXTENSION: Option<&'static str>

The template’s extension, if provided

source

const SIZE_HINT: usize

Provides a conservative estimate of the expanded length of the rendered template

source

const MIME_TYPE: &'static str

The MIME type (Content-Type) of the data that gets rendered by this Template

Required Methods§

source

fn render_into(&self, writer: &mut impl Write) -> Result<(), Error>

Renders the template to the given writer fmt buffer

Provided Methods§

source

fn render(&self) -> Result<String, Error>

Helper method which allocates a new String and renders into it

source

fn write_into(&self, writer: &mut impl Write) -> Result<(), Error>

Renders the template to the given writer io buffer

Implementors§