Trait quickjs_rs::Callback
source · pub trait Callback<F>: RefUnwindSafe {
// Required methods
fn argument_count(&self) -> usize;
fn call(
&self,
args: Vec<JsValue>
) -> Result<Result<JsValue, String>, ValueError>;
}
Expand description
The Callback trait is implemented for functions/closures that can be used as callbacks in the JS runtime.
Required Methods§
sourcefn argument_count(&self) -> usize
fn argument_count(&self) -> usize
Returns the number of required Javascript arguments.
sourcefn call(
&self,
args: Vec<JsValue>
) -> Result<Result<JsValue, String>, ValueError>
fn call( &self, args: Vec<JsValue> ) -> Result<Result<JsValue, String>, ValueError>
Execute the callback.
Should return:
- Err(_) if the JS values could not be converted
- Ok(Err(_)) if an error ocurred while processing. The given error will be raised as a JS exception.
- Ok(Ok(result)) when execution succeeded.