So, I've been writing a library at work which is targeted to be published to both crates.io and npm. Things aren't as straightforward as one would like, but now I feel I know what to start asking.
So the library is pretty simple, it takes in data and buffers it before sending it to a REST API. The Rust version is written as a background thread, and now I have single threaded version for wasm.
First question is about the project layout. Is it better to have all code in a single crate or split it into common, rust and wasm crates?
The second is about the public non-Copy struct fields, Strings in this case. As wasm-bindgen doesn't support them, should I look into some kind of serde serialization/deserialization scheme? Right now the struct is in the common code crate and is the actual data that is buffered and later sent.
I tried making the fields private and implement getters&setters, but they don't work either because with #[wasm_bindgen] I can't return borrowed references to the fields. Cloning them doesn't sound like a very good plan.
Final question is about typescript. Apparently wasm-pack generates some type definitions? A bit earlier I managed to get wasm-pack to succefully build the project, but the d.ts files were empty. Given that I have couple public funtions in the wasm crate and public structs in the common crate, should I expect to get types for those from wasm-pack, or will I need to write them myself?