pub struct Template<'tpl> { /* private fields */ }
Expand description
A preprocessed form of the plain text template, ready to be rendered
with data contained in types implementing the Content
trait.
Implementations
sourceimpl<'tpl> Template<'tpl>
impl<'tpl> Template<'tpl>
sourcepub fn new<S>(source: S) -> Result<Self, Error> where
S: Into<Cow<'tpl, str>>,
pub fn new<S>(source: S) -> Result<Self, Error> where
S: Into<Cow<'tpl, str>>,
Create a new Template
out of the source.
- If
source
is a&str
, thisTemplate
will borrow it with appropriate lifetime. - If
source
is aString
, thisTemplate
will take it’s ownership (The'tpl
lifetime will be'static
).
sourcepub fn capacity_hint(&self) -> usize
pub fn capacity_hint(&self) -> usize
Estimate how big of a buffer should be allocated to render this Template
.
sourcepub fn render<C: Content>(&self, content: &C) -> String
pub fn render<C: Content>(&self, content: &C) -> String
Render this Template
with a given Content
to a String
.
sourcepub fn render_to_writer<W, C>(&self, writer: &mut W, content: &C) -> Result<()> where
W: Write,
C: Content,
pub fn render_to_writer<W, C>(&self, writer: &mut W, content: &C) -> Result<()> where
W: Write,
C: Content,
Render this Template
with a given Content
to a writer.
Auto Trait Implementations
impl<'tpl> RefUnwindSafe for Template<'tpl>
impl<'tpl> Send for Template<'tpl>
impl<'tpl> Sync for Template<'tpl>
impl<'tpl> Unpin for Template<'tpl>
impl<'tpl> UnwindSafe for Template<'tpl>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more