#structs #macro #js-value #convert #js-values #serde-wasm-bindgen

rs2js

A macro to convert Rust structs to/from JsValues

5 releases

0.2.3 Jun 13, 2023
0.2.2 Jun 13, 2023
0.2.1 Jun 13, 2023
0.2.0 May 2, 2023
0.1.0 May 2, 2023

#3 in #js-value

MIT/Apache

3KB

Rs2Js: Rust to JsValue and back again

Usage

#[derive(Rs2Js, Debug, Clone, PartialEq)]
pub struct DbProject {
    pub name: String,
    pub owner_id: String,
    pub created: Timestamp,
}
fn main() {
    let proj = DbProject { .. };
    let value = proj.to_js(); // JsValue
}

Motivation

This mostly exists because serde-wasm-bindgen currently doesn't support passing through JsValues (see this issue).

Dependencies

~1.4–2.3MB
~40K SLoC