pub trait Function:
Send
+ Sync
+ 'static {
// Required methods
fn name(&self) -> &'static str;
fn eval<'a, 'b, 'c>(
&self,
args: &'c [ArgumentHandle<'a, 'b>],
ctx: &dyn FunctionContext<'b>,
) -> Result<CalcValue<'b>, 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_reference<'a, 'b, 'c>(
&self,
_args: &'c [ArgumentHandle<'a, 'b>],
_ctx: &dyn FunctionContext<'b>,
) -> Option<Result<ReferenceType, ExcelError>> { ... }
fn dispatch<'a, 'b, 'c>(
&self,
args: &'c [ArgumentHandle<'a, 'b>],
ctx: &dyn FunctionContext<'b>,
) -> Result<CalcValue<'b>, 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<'a, 'b, 'c>(
&self,
args: &'c [ArgumentHandle<'a, 'b>],
ctx: &dyn FunctionContext<'b>,
) -> Result<CalcValue<'b>, ExcelError>
fn eval<'a, 'b, 'c>( &self, args: &'c [ArgumentHandle<'a, 'b>], ctx: &dyn FunctionContext<'b>, ) -> Result<CalcValue<'b>, ExcelError>
The unified evaluation path.
This method replaces the separate scalar, fold, and map paths.
Functions use the provided ArgumentHandles to access inputs as either
scalars or RangeViews (Arrow-backed virtual ranges).
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_reference<'a, 'b, 'c>(
&self,
_args: &'c [ArgumentHandle<'a, 'b>],
_ctx: &dyn FunctionContext<'b>,
) -> Option<Result<ReferenceType, ExcelError>>
fn eval_reference<'a, 'b, 'c>( &self, _args: &'c [ArgumentHandle<'a, 'b>], _ctx: &dyn FunctionContext<'b>, ) -> 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, 'c>(
&self,
args: &'c [ArgumentHandle<'a, 'b>],
ctx: &dyn FunctionContext<'b>,
) -> Result<CalcValue<'b>, ExcelError>
fn dispatch<'a, 'b, 'c>( &self, args: &'c [ArgumentHandle<'a, 'b>], ctx: &dyn FunctionContext<'b>, ) -> Result<CalcValue<'b>, ExcelError>
Dispatch to the unified evaluation path with automatic argument validation.