wasm_bindgen::convert

Trait TryFromJsValue

source
pub trait TryFromJsValue: Sized {
    type Error;

    // Required method
    fn try_from_js_value(value: JsValue) -> Result<Self, Self::Error>;
}
Expand description

TryFromJsValue is a trait for converting a JavaScript value (JsValue) into a Rust type. It is used by the wasm_bindgen proc-macro to allow conversion to user types.

Types implementing this trait must specify their conversion logic from JsValue to the Rust type, handling any potential errors that may occur during the conversion process.

§⚠️ Unstable

This is part of the internal convert module, no stability guarantees are provided. Use at your own risk. See its documentation for more details.

Required Associated Types§

source

type Error

The type returned in the event of a conversion error.

Required Methods§

source

fn try_from_js_value(value: JsValue) -> Result<Self, Self::Error>

Performs the conversion.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl TryFromJsValue for String

Implementors§