I have a rust program which I would like to run as web assembly in javascript. I have a function which I want to return a 3D array, so I can plot some data on a graph on the frontend, but I cannot find a way to return such data. Having a look at js_sys there is no general Array type, only specific types for 2D arrays such as Uint32Array.
I would like the function signature to look something like this:
#[wasm_bindgen]
pub fn sk_dataset(input: &str) -> Vec<Vec<i32>>;
I have tried return a struct with the wasm_bindgen decorator like this:
#[wasm_bindgen]
pub struct DataSet {
pub data: Vec<Vec<i32>>
}
But I get an error stating that
the trait bound `Vec<i32>: JsObject` is not satisfied
required because of the requirements on the impl of `IntoWasmAbi` for `Box<[Vec<i32>]>`
The tutorial over at https://rustwasm.github.io/docs/wasm-bindgen/reference/types/exported-rust-types.html only has examples of structs exported with basic types like i32s, how can I export a struct with more complex members?