#Wasm Builder Pattern
26 messages · Page 1 of 1 (latest)
For what purpose exactly ?
Writing a Libary in Rust and using it on multiple platforms from python.
So you're looking for interoperability with python ?
If that's the case then you'll probably be interested in pyo3
Yes. But I find the thought good to write something not for a single target. That's why I thought of WASM.
Oh, so you simply want to target wasm with your rust code ?
I want to write rust code that I can use on multiple targets from multiple languages.
How could I make a builder pattern like in Rust so that I can use the pattern in my Javascript code ? 🤔
I have trouble seeing how that could be made ?
Because I should only return primitive types from my Wasm functions, right ?
If you're using wasm_bindgen then it should be pretty straightforward
As in just write your regular builder and slap #[wasm_bindgen] on the type definition and the impl blocks
@wary verge Update : I tried to do so, unsuccessfully, saying I could not return a mutable reference in wasm
ah, indeed. You'd need to use a "by value" builder probably
Yes, I believe so, I'm experimenting !
for reference, I have this in some project: https://github.com/Globidev/corewa-rs/blob/master/corewa-rs-wasm/src/vm.rs#L107-L131
Thanks so much
Have you played with js_name / optionnal param for rust exported function ?
js_name sure, optional parameters not so much