pub trait Function:
Send
+ Sync
+ 'static {
Show 15 methods
// Required methods
fn name(&self) -> &'static str;
fn eval_scalar<'a, 'b>(
&self,
args: &'a [ArgumentHandle<'a, 'b>],
ctx: &dyn FunctionContext,
) -> Result<LiteralValue, ExcelError>;
// Provided methods
fn caps(&self) -> FnCaps { ... }
fn namespace(&self) -> &'static str { ... }
fn min_args(&self) -> usize { ... }
fn variadic(&self) -> bool { ... }
fn volatile(&self) -> bool { ... }
fn arg_schema(&self) -> &'static [ArgSchema] { ... }
fn aliases(&self) -> &'static [&'static str] { ... }
fn function_salt(&self) -> u64 { ... }
fn eval_fold(
&self,
_f: &mut dyn FnFoldCtx,
) -> Option<Result<LiteralValue, ExcelError>> { ... }
fn eval_map(
&self,
_m: &mut dyn FnMapCtx,
) -> Option<Result<LiteralValue, ExcelError>> { ... }
fn eval_window<'a, 'b>(
&self,
_w: &mut SimpleWindowCtx<'a, 'b>,
) -> Option<Result<LiteralValue, ExcelError>> { ... }
fn eval_reference<'a, 'b>(
&self,
_args: &'a [ArgumentHandle<'a, 'b>],
_ctx: &dyn FunctionContext,
) -> Option<Result<ReferenceType, ExcelError>> { ... }
fn dispatch<'a, 'b>(
&self,
args: &'a [ArgumentHandle<'a, 'b>],
ctx: &dyn FunctionContext,
) -> Result<LiteralValue, ExcelError> { ... }
}Expand description
Revised, object-safe trait for all Excel-style functions.
This trait uses a capability-based model (FnCaps) to declare function
properties, enabling the evaluation engine to select the most optimal
execution path (e.g., scalar, vectorized, parallel).
Required Methods§
fn name(&self) -> &'static str
Sourcefn eval_scalar<'a, 'b>(
&self,
args: &'a [ArgumentHandle<'a, 'b>],
ctx: &dyn FunctionContext,
) -> Result<LiteralValue, ExcelError>
fn eval_scalar<'a, 'b>( &self, args: &'a [ArgumentHandle<'a, 'b>], ctx: &dyn FunctionContext, ) -> Result<LiteralValue, ExcelError>
The default, scalar evaluation path.
This method is the fallback for all functions and the only required evaluation path. It processes arguments one by one.
Provided Methods§
fn namespace(&self) -> &'static str
fn min_args(&self) -> usize
fn variadic(&self) -> bool
fn volatile(&self) -> bool
fn arg_schema(&self) -> &'static [ArgSchema]
Sourcefn aliases(&self) -> &'static [&'static str]
fn aliases(&self) -> &'static [&'static str]
Optional list of additional alias names (case-insensitive) that should resolve to this function. Default: empty slice. Implementors can override to expose legacy names. Returned slice must have ’static lifetime (typically a static array reference).
fn function_salt(&self) -> u64
Sourcefn eval_fold(
&self,
_f: &mut dyn FnFoldCtx,
) -> Option<Result<LiteralValue, ExcelError>>
fn eval_fold( &self, _f: &mut dyn FnFoldCtx, ) -> Option<Result<LiteralValue, ExcelError>>
An optional, optimized path for reduction functions (e.g., SUM, COUNT).
This method is called by the engine if the REDUCTION capability is set.
It operates on a FnFoldCtx which provides efficient access to input data.
Sourcefn eval_map(
&self,
_m: &mut dyn FnMapCtx,
) -> Option<Result<LiteralValue, ExcelError>>
fn eval_map( &self, _m: &mut dyn FnMapCtx, ) -> Option<Result<LiteralValue, ExcelError>>
An optional, optimized path for element-wise functions (e.g., SIN, ABS).
This method is called by the engine if the ELEMENTWISE capability is set.
It operates on a FnMapCtx which provides direct access to input/output
data stripes for vectorized processing.
Sourcefn eval_window<'a, 'b>(
&self,
_w: &mut SimpleWindowCtx<'a, 'b>,
) -> Option<Result<LiteralValue, ExcelError>>
fn eval_window<'a, 'b>( &self, _w: &mut SimpleWindowCtx<'a, 'b>, ) -> Option<Result<LiteralValue, ExcelError>>
An optional, optimized path for windowed functions (e.g., MOVING_AVERAGE).
This method is called by the engine if the WINDOWED capability is set.
Sourcefn eval_reference<'a, 'b>(
&self,
_args: &'a [ArgumentHandle<'a, 'b>],
_ctx: &dyn FunctionContext,
) -> Option<Result<ReferenceType, ExcelError>>
fn eval_reference<'a, 'b>( &self, _args: &'a [ArgumentHandle<'a, 'b>], _ctx: &dyn FunctionContext, ) -> Option<Result<ReferenceType, ExcelError>>
Optional reference result path. Only called by the interpreter/engine when the callsite expects a reference (e.g., range combinators, by-ref argument positions, or spill sources).
Default implementation returns None, indicating the function does not
support returning references. Functions that set RETURNS_REFERENCE
should override this.
Sourcefn dispatch<'a, 'b>(
&self,
args: &'a [ArgumentHandle<'a, 'b>],
ctx: &dyn FunctionContext,
) -> Result<LiteralValue, ExcelError>
fn dispatch<'a, 'b>( &self, args: &'a [ArgumentHandle<'a, 'b>], ctx: &dyn FunctionContext, ) -> Result<LiteralValue, ExcelError>
Dispatch to the most optimal evaluation path based on capabilities. This default implementation checks caps and calls the appropriate eval method.