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§
Sourcefn call_function(
&self,
function_name: &str,
arguments: &[Value],
) -> Option<Value>
fn call_function( &self, function_name: &str, arguments: &[Value], ) -> Option<Value>
None means the name is unknown.
Sourcefn function_names(&self) -> Vec<&'static str>
fn function_names(&self) -> Vec<&'static str>
Every name call_function answers, so the engine can offer them to templates.
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".