pub trait Template: RenderOnce + Sized {
// Provided methods
fn into_string(self) -> Result<String, Error> { ... }
fn write_to_string(self, string: &mut String) -> Result<(), Error> { ... }
fn write_to_fmt(self, writer: &mut dyn Write) -> Result<(), Error> { ... }
fn write_to_io(self, writer: &mut dyn Write) -> Result<(), Error> { ... }
}Expand description
A template that can be rendered into something.
Don’t let the single impl below fool you, these methods are available on all Render*’s
(through impls on references and boxes).
Provided Methods§
Sourcefn into_string(self) -> Result<String, Error>
fn into_string(self) -> Result<String, Error>
Render this into a new String.
FEATURE: requires “alloc”.
Sourcefn write_to_string(self, string: &mut String) -> Result<(), Error>
fn write_to_string(self, string: &mut String) -> Result<(), Error>
Render this into an existing String.
Note: You could also use render_into_fmt but this is noticeably faster.
FEATURE: requires “alloc”.
Sourcefn write_to_fmt(self, writer: &mut dyn Write) -> Result<(), Error>
fn write_to_fmt(self, writer: &mut dyn Write) -> Result<(), Error>
Render this into something that implements fmt::Write.
FnRenderer also implements Display but that’s about twice as slow…
Sourcefn write_to_io(self, writer: &mut dyn Write) -> Result<(), Error>
fn write_to_io(self, writer: &mut dyn Write) -> Result<(), Error>
Render this into something that implements io::Write.
Note: If you’re writing directly to a file/socket etc., you should seriously consider wrapping your writer in a BufWriter. Otherwise, you’ll end up making quite a few unnecessary system calls.
FEATURE: requires “std”.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.