Skip to main content

TemplateFunctions

Trait TemplateFunctions 

Source
pub trait TemplateFunctions: Send + Sync {
    // Required methods
    fn call_function(
        &self,
        function_name: &str,
        arguments: &[Value],
    ) -> Option<Value>;
    fn function_names(&self) -> Vec<&'static str>;
    fn to_shared(&self) -> Arc<dyn TemplateFunctions> ⓘ;
}
Expand description

The functions a template may call, such as uuid(). Keyword arguments arrive as one object after the positional ones.

Required Methods§

Source

fn call_function( &self, function_name: &str, arguments: &[Value], ) -> Option<Value>

None means the name is unknown.

Source

fn function_names(&self) -> Vec<&'static str>

Every name call_function answers, so the engine can offer them to templates.

Source

fn to_shared(&self) -> Arc<dyn TemplateFunctions> ⓘ

A shared copy the engine keeps while it renders.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§