I am writing an l-system generator using wasm-bindgen. The UI will be written in Javascript, whereas the rust code is responsible for parsing, evaluation, and geometry generation.
My aim is to pass a string representation of the system to rust, and rust will return a zero-copy buffer of geometry primitives which will be rendered in JS. It seems that the best way to do this is with Uint8Array::view
. This method has a few unsafety caveats which make sense, except for the following:
Finally, the returned object is disconnected from the input slice’s lifetime, so there’s no guarantee that the data is read at the right time.
What exactly does this mean? Is this referring to the situation where the input slice is dropped before the JS actually receives the Uint8Array
? Or is there another way for the data to be read at the "wrong" time?