pub struct FileLoader<H: BuildHasher + Default = FnvBuildHasher> { /* private fields */ }Expand description
Lazily loads templates on-demand during render. Caches some compiled templates in memory.
§Examples
Creating a FileLoader from a LoaderConfig:
use moostache::{LoaderConfig, FileLoader};
let loader = FileLoader::try_from(LoaderConfig::default()).unwrap();Trait Implementations§
Source§impl<H: Debug + BuildHasher + Default> Debug for FileLoader<H>
impl<H: Debug + BuildHasher + Default> Debug for FileLoader<H>
Source§impl TemplateLoader for FileLoader
impl TemplateLoader for FileLoader
Source§type Error = MoostacheError
type Error = MoostacheError
Error type of the
get and render methods.Source§fn get(&self, name: &str) -> Result<Rc<Template>, MoostacheError>
fn get(&self, name: &str) -> Result<Rc<Template>, MoostacheError>
Get a template by name. Read more
Source§fn insert(&mut self, name: String, value: Template) -> Option<Template>
fn insert(&mut self, name: String, value: Template) -> Option<Template>
Insert a template by name.
Source§fn render<W: Write>(
&self,
name: &str,
value: &Value,
writer: &mut W,
) -> Result<(), Self::Error>
fn render<W: Write>( &self, name: &str, value: &Value, writer: &mut W, ) -> Result<(), Self::Error>
Render a template by name, using a
serde_json::Value
as data and writing output to a &mut impl Write. Read moreSource§fn render_serializable<W: Write, S: Serialize>(
&self,
name: &str,
serializeable: &S,
writer: &mut W,
) -> Result<(), Self::Error>
fn render_serializable<W: Write, S: Serialize>( &self, name: &str, serializeable: &S, writer: &mut W, ) -> Result<(), Self::Error>
Render a template by name, using a type which impls
serde::Serialize as data and writing output to a
&mut impl Write. Read moreSource§impl TryFrom<LoaderConfig<'_>> for FileLoader
impl TryFrom<LoaderConfig<'_>> for FileLoader
Source§type Error = MoostacheError
type Error = MoostacheError
The type returned in the event of a conversion error.
Source§fn try_from(config: LoaderConfig<'_>) -> Result<Self, MoostacheError>
fn try_from(config: LoaderConfig<'_>) -> Result<Self, MoostacheError>
Performs the conversion.
Auto Trait Implementations§
impl<H = BuildHasherDefault<FnvHasher>> !Freeze for FileLoader<H>
impl<H = BuildHasherDefault<FnvHasher>> !RefUnwindSafe for FileLoader<H>
impl<H = BuildHasherDefault<FnvHasher>> !Send for FileLoader<H>
impl<H = BuildHasherDefault<FnvHasher>> !Sync for FileLoader<H>
impl<H> Unpin for FileLoader<H>where
H: Unpin,
impl<H> UnwindSafe for FileLoader<H>where
H: UnwindSafe,
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