Skip to main content

ExpressionPlugin

Trait ExpressionPlugin 

Source
pub trait ExpressionPlugin:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &str;
    fn overloads(&self) -> Vec<ExprOverloadDesc>;
    fn evaluate(
        &self,
        overload_index: usize,
        args: &[ExprArg<'_>],
        cx: &ExprEvalCx<'_>,
    ) -> Result<ExprValue, String>;
}
Expand description

A custom MapLibre style expression function implemented in Rust.

Implementations must be thread-safe (Send + Sync + 'static) because evaluation may run on the render thread, tile layout worker threads, or standalone expression evaluation threads concurrently.

Required Methods§

Source

fn name(&self) -> &str

Operator name as written in style JSON (for example "acme:scale").

Source

fn overloads(&self) -> Vec<ExprOverloadDesc>

One or more overload signatures accepted by this function.

Source

fn evaluate( &self, overload_index: usize, args: &[ExprArg<'_>], cx: &ExprEvalCx<'_>, ) -> Result<ExprValue, String>

Evaluates the overload at overload_index against already-evaluated args and optional runtime context cx.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§