Expand description

Serialization and deserialization functions that pass JavaScript objects through unchanged.

This module is compatible with the serde(with) annotation, so for example if you create the struct

#[derive(serde::Serialize)]
struct MyStruct {
    int_field: i32,
    #[serde(with = "serde_wasm_bindgen::preserve")]
    js_field: js_sys::Int8Array,
}

let s = MyStruct {
    int_field: 5,
    js_field: js_sys::Int8Array::new_with_length(1000),
};

then serde_wasm_bindgen::to_value(&s) will return a JsValue representing an object with two fields (int_field and js_field), where js_field will be an Int8Array pointing to the same underlying JavaScript object as s.js_field does.

Functions§