pub trait Callable: Object {
// Required method
fn call(&self, cx: &mut Cx, args: Args) -> Result<Value>;
// Provided methods
fn browse_args_shape(&self, _cx: &mut Cx) -> Result<Option<ShapeRef>> { ... }
fn browse_result_shape(&self, _cx: &mut Cx) -> Result<Option<ShapeRef>> { ... }
fn call_exprs(&self, cx: &mut Cx, args: RawArgs) -> Result<Value> { ... }
}Expand description
Runtime protocol for values that can be called.
Functions, constructors, macros that accept raw expressions, and host or
guest function stubs all share this protocol. A callable is always a
runtime object, so it also has a class, display form, reflection table, and
optional protocol views through Object.
Required Methods§
Provided Methods§
Sourcefn browse_args_shape(&self, _cx: &mut Cx) -> Result<Option<ShapeRef>>
fn browse_args_shape(&self, _cx: &mut Cx) -> Result<Option<ShapeRef>>
Optional shape describing the accepted argument list, for browsing.
Sourcefn browse_result_shape(&self, _cx: &mut Cx) -> Result<Option<ShapeRef>>
fn browse_result_shape(&self, _cx: &mut Cx) -> Result<Option<ShapeRef>>
Optional shape describing the call result, for browsing.
Sourcefn call_exprs(&self, cx: &mut Cx, args: RawArgs) -> Result<Value>
fn call_exprs(&self, cx: &mut Cx, args: RawArgs) -> Result<Value>
Invoke the callable on raw, unevaluated argument expressions.
The default evaluates each expression in cx and forwards to
Callable::call; macro-like callables override to inspect raw forms.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".