Trait blue_build_template::Template

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

    // Required method
    fn render_into<W>(&self, writer: &mut W) -> Result<(), Error>
       where W: Write + ?Sized;

    // Provided methods
    fn render(&self) -> Result<String, Error> { ... }
    fn write_into<W>(&self, writer: &mut W) -> Result<(), Error>
       where W: Write + ?Sized { ... }
}
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 rough estimate of the expanded length of the rendered template. Larger values result in higher memory usage but fewer reallocations. Smaller values result in the opposite. This value only affects render. It does not take effect when calling render_into, write_into, the fmt::Display implementation, or the blanket ToString::to_string implementation.

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<W>(&self, writer: &mut W) -> Result<(), Error>
where W: Write + ?Sized,

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<W>(&self, writer: &mut W) -> Result<(), Error>
where W: Write + ?Sized,

Renders the template to the given writer io buffer

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> Template for &T
where T: Template + ?Sized,

source§

const EXTENSION: Option<&'static str> = T::EXTENSION

source§

const SIZE_HINT: usize = T::SIZE_HINT

source§

const MIME_TYPE: &'static str = T::MIME_TYPE

source§

fn render_into<W>(&self, writer: &mut W) -> Result<(), Error>
where W: Write + ?Sized,

source§

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

source§

fn write_into<W>(&self, writer: &mut W) -> Result<(), Error>
where W: Write + ?Sized,

Implementors§

source§

impl<'a> Template for ContainerFileTemplate<'a>

source§

const EXTENSION: Option<&'static str> = _

source§

const SIZE_HINT: usize = 2_456usize

source§

const MIME_TYPE: &'static str = "application/octet-stream"

source§

impl<'a> Template for GithubIssueTemplate<'a>

source§

const EXTENSION: Option<&'static str> = _

source§

const SIZE_HINT: usize = 684usize

source§

const MIME_TYPE: &'static str = "application/octet-stream"

source§

impl<'a> Template for InitReadmeTemplate<'a>

source§

const EXTENSION: Option<&'static str> = _

source§

const SIZE_HINT: usize = 1_826usize

source§

const MIME_TYPE: &'static str = "application/octet-stream"