FileLoader

Struct FileLoader 

Source
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>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl TemplateLoader for FileLoader

Source§

type Output<'a> = Rc<Template>

Output type of the get method.
Source§

type Error = MoostacheError

Error type of the get and render methods.
Source§

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>

Insert a template by name.
Source§

fn remove(&mut self, name: &str) -> Option<Template>

Remove a template by name.
Source§

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 more
Source§

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 more
Source§

fn render_to_string( &self, name: &str, value: &Value, ) -> Result<String, Self::Error>

Renders a template by name, using a serde_json::Value as data and returning the output as a String. Read more
Source§

fn render_serializable_to_string<S: Serialize>( &self, name: &str, serializable: &S, ) -> Result<String, Self::Error>

Renders a template by name, using a type which impls serde::Serialize as data and returning the output as a String. Read more
Source§

impl TryFrom<LoaderConfig<'_>> for FileLoader

Source§

type Error = MoostacheError

The type returned in the event of a conversion error.
Source§

fn try_from(config: LoaderConfig<'_>) -> Result<Self, MoostacheError>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,