Trait JsArg
pub trait JsArg: Sized {
// Required method
fn from_js(value: JsValue) -> Result<Self, JsError>;
// Provided method
fn from_missing_js_arg() -> Result<Self, JsError> { ... }
}Available on crate features
js and std only.Expand description
A typed host function argument, extracted from a JsValue.
Implemented for primitives, strings, common network types and
containers; see the crate documentation for the full list. Implement
it for your own types to use them directly as typed arguments in
host functions registered via
JsRuntimeBuilder::with_fn.
A failed extraction is thrown as a TypeError inside the
calling script.
Required Methods§
Provided Methods§
fn from_missing_js_arg() -> Result<Self, JsError>
fn from_missing_js_arg() -> Result<Self, JsError>
Extract this argument when the caller did not provide it.
Defaults to an arity error; optional arguments override this.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".