pub struct Callable<'a> { /* private fields */ }Expand description
A function passed to a HostFunction, which it can call while it runs (ADR 0011). Given
by HostCall::function.
Implementations§
Source§impl Callable<'_>
impl Callable<'_>
Sourcepub fn arity(&self) -> usize
pub fn arity(&self) -> usize
The number of declared parameters, as HostFunction::arity gives for a host function.
Sourcepub fn call(&self, args: &[Option<JsonValue>]) -> Result<Option<JsonValue>>
pub fn call(&self, args: &[Option<JsonValue>]) -> Result<Option<JsonValue>>
Applies the function to args, as $map applies its function: extra arguments are
passed on, missing ones are undefined, and the context value is null. A lambda keeps
the variables of its definition.
Arguments and the result cross the boundary as JSON, as for the host function itself: a
sequence comes back as an array or a single value, and a function as None.
The call is part of the evaluation: it counts as a level of depth and checks the
timeout and the cancellation token, its result is limited like the evaluation’s
(Options::max_result_size), and an audit shows its steps under the host function’s
call. Its errors come back with their codes; returning one ends the evaluation, as any
error from the expression does.