pub struct Template { /* 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 Template
impl Template
sourcepub fn new(source: &str) -> Result<Template, TemplateError>
pub fn new(source: &str) -> Result<Template, TemplateError>
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>(&self, content: &C) -> Stringwhere
C: for<'section> Content,
pub fn render<C>(&self, content: &C) -> Stringwhere
C: for<'section> Content,
Render this Template with a given Content to a String.
sourcepub fn render_sql<C>(&self, content: &C) -> Stringwhere
C: for<'section> Content,
pub fn render_sql<C>(&self, content: &C) -> Stringwhere
C: for<'section> Content,
Render this Template with a given Content to a String.
sourcepub fn render_to_writer<W, C>(
&self,
writer: &mut W,
content: &C
) -> Result<(), Error>
pub fn render_to_writer<W, C>( &self, writer: &mut W, content: &C ) -> Result<(), Error>
Render this Template with a given Content to a writer.
sourcepub fn render_to_file<P, C>(&self, path: P, content: &C) -> Result<(), Error>
pub fn render_to_file<P, C>(&self, path: P, content: &C) -> Result<(), Error>
Render this Template with a given Content to a file.
sourcepub fn deserialize(bin_content: &[u8]) -> Template
pub fn deserialize(bin_content: &[u8]) -> Template
Deserialize template from Vec
Trait Implementations§
source§impl<'de> Deserialize<'de> for Template
impl<'de> Deserialize<'de> for Template
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<Template, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Template, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Serialize for Template
impl Serialize for Template
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for Template
impl RefUnwindSafe for Template
impl Send for Template
impl Sync for Template
impl Unpin for Template
impl UnwindSafe for Template
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