Skip to main content

Function

Trait Function 

Source
pub trait Function:
    Send
    + Sync
    + 'static {
Show 14 methods // 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 dependency_contract( &self, _arity: usize, ) -> Option<FunctionDependencyContract> { ... } fn semantic_contract( &self, _arity: usize, ) -> Option<FunctionSemanticContract> { ... } 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§

Source

fn name(&self) -> &'static str

Source

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§

Source

fn caps(&self) -> FnCaps

Capability flags for this function

Source

fn namespace(&self) -> &'static str

Source

fn min_args(&self) -> usize

Source

fn variadic(&self) -> bool

Source

fn volatile(&self) -> bool

Source

fn arg_schema(&self) -> &'static [ArgSchema]

Source

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).

Source

fn dependency_contract( &self, _arity: usize, ) -> Option<FunctionDependencyContract>

Optional dependency contract for passive planning/FormulaPlane analysis.

The default is deliberately conservative: functions that do not opt in must not receive dependency-summary optimization. Implementations should return Some only for arities and argument roles they can describe without under-approximating dependencies.

Source

fn semantic_contract(&self, _arity: usize) -> Option<FunctionSemanticContract>

Explicit semantic classification for this call arity.

The public default is intentionally untrusted. The registry supplies a sealed default only for crate-owned builtin registration.

Source

fn function_salt(&self) -> u64

Source

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.

Source

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.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§