pub trait Function:
Send
+ Sync
+ Debug {
Show 13 methods
// Required methods
fn identifier(&self) -> &'static str;
fn usage(&self) -> &'static str;
fn category(&self) -> &'static str;
fn return_kind(&self) -> u16;
fn examples(&self) -> &'static [Example];
fn compile(
&self,
state: &TypeState,
ctx: &mut FunctionCompileContext,
arguments: ArgumentList,
) -> Compiled;
// Provided methods
fn summary(&self) -> &'static str { ... }
fn internal_failure_reasons(&self) -> &'static [&'static str] { ... }
fn return_rules(&self) -> &'static [&'static str] { ... }
fn notices(&self) -> &'static [&'static str] { ... }
fn pure(&self) -> bool { ... }
fn parameters(&self) -> &'static [Parameter] { ... }
fn closure(&self) -> Option<Definition> { ... }
}Required Methods§
Sourcefn identifier(&self) -> &'static str
fn identifier(&self) -> &'static str
The identifier by which the function can be called.
Sourcefn usage(&self) -> &'static str
fn usage(&self) -> &'static str
A more elaborate multi-paragraph description on how to use the function.
Sourcefn category(&self) -> &'static str
fn category(&self) -> &'static str
The category this function belongs to.
This categorizes functions for documentation and tooling purposes.
Sourcefn return_kind(&self) -> u16
fn return_kind(&self) -> u16
The return type kind(s) this function can return.
Sourcefn examples(&self) -> &'static [Example]
fn examples(&self) -> &'static [Example]
One or more examples demonstrating usage of the function in VRL source code.
Sourcefn compile(
&self,
state: &TypeState,
ctx: &mut FunctionCompileContext,
arguments: ArgumentList,
) -> Compiled
fn compile( &self, state: &TypeState, ctx: &mut FunctionCompileContext, arguments: ArgumentList, ) -> Compiled
Compile a Function into a type that can be resolved to an
Expression.
This function is called at compile-time for any Function used in the
program.
At runtime, the Expression returned by this function is executed and
resolved to its final Value.
Provided Methods§
Sourcefn summary(&self) -> &'static str
fn summary(&self) -> &'static str
A brief single-line description explaining what this function does.
Sourcefn internal_failure_reasons(&self) -> &'static [&'static str]
fn internal_failure_reasons(&self) -> &'static [&'static str]
Human-readable internal failure reasons for the function.
This returns an empty slice by default, indicating no internal failure reasons are documented for a function.
Sourcefn return_rules(&self) -> &'static [&'static str]
fn return_rules(&self) -> &'static [&'static str]
Human-readable rules describing the return value of the function.
This returns an empty slice by default, indicating no return rules are documented for this function.
Sourcefn notices(&self) -> &'static [&'static str]
fn notices(&self) -> &'static [&'static str]
Important notices about the function’s behavior or usage.
This returns an empty slice by default, indicating no notices are documented for this function.
Sourcefn pure(&self) -> bool
fn pure(&self) -> bool
Whether a function is pure or not. When a function is pure, it is idempotent and has no side-effects. Otherwise, it is impure.
Sourcefn parameters(&self) -> &'static [Parameter]
fn parameters(&self) -> &'static [Parameter]
An optional list of parameters the function accepts.
This list is used at compile-time to check function arity, keyword names and argument type definition.
Sourcefn closure(&self) -> Option<Definition>
fn closure(&self) -> Option<Definition>
An optional closure definition for the function.
This returns None by default, indicating the function doesn’t accept
a closure.