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§
Source§impl<'tpl> Template<'tpl>
impl<'tpl> Template<'tpl>
Sourcepub fn new<S>(source: S) -> Result<Self, Error>
pub fn new<S>(source: S) -> Result<Self, Error>
Create a new Template out of the source.
- If
sourceis a&str, thisTemplatewill borrow it with appropriate lifetime. - If
sourceis aString, thisTemplatewill take it’s ownership (The'tpllifetime 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<()>
pub fn render_to_writer<W, C>(&self, writer: &mut W, content: &C) -> Result<()>
Render this Template with a given Content to a writer.
Sourcepub fn render_to_file<P, C>(&self, path: P, content: &C) -> Result<()>
pub fn render_to_file<P, C>(&self, path: P, content: &C) -> Result<()>
Render this Template with a given Content to a file.
Trait Implementations§
Auto Trait Implementations§
impl<'tpl> Freeze for Template<'tpl>
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more