Is there a comprehensive explanation of usage of number slices with wasm_bindgen?

I'm trying to work on some image processing stuff so I need to pass a lot of number slices (for raw files or decoded arrays) between JS and wasm (rust). My issue is that the behavior of wasm_bindgen for this use case isn't clear to me at all. The documentation on this subject is extremely sparse, basically just the "Number slices" and "Boxed number slices" sections of the book, which do not explain what happens at the frontier.

I would love to find a resource explaining the exact behaviors and concrete differences of each possible approach. For example, to return a [u8], it seems one could return a Box<[u8]>, or a pointer and a size, or a JsValue holding a typed array. What are the tradeoffs of each approach? are they equivalent? when is the memory release? how much copy is happening? which is more suited for short-lived values, long-lived values? etc.

I have a good understanding of wasm in general. I know about the linear memory model, the sharing that can only happen with the wasm memory, etc. But there is a lot of magic with wasm_bindgen and I can't seem to find a good resource on the subject of big data slices. If you have one such resource on the subject please share! :slight_smile: