I have a function written in Rust that takes a parameter of usize
, and returns a mut u8
. How do I call this type of function in Python?
Wasm only has the i32
and i64
types. usize
maps to i32
as wasm uses 32bit pointers. Everything smaller than i32
also maps to i32
. I am not sure if it is zero or sign extended though.
What I have done was casting my int to int32 using NumPy. However, I get an error when converting.
What is the error?
In the example I don't see any casting necessary: https://github.com/bytecodealliance/wasmtime-py/blob/82e61606594b5fbf7199a2e9a1fbbc881261abbb/examples/multi.py#L33-L34
When I called a function that returns a mutable u8
, I get a mut u8
1209328 from Rust. However, I need to use that value in another Wasm function, and it fails because it cannot be casted to int32 for some reason.
I unfortunately don't think I can help any further. I haven't ever used wasmtime-py.
Thank you for the help.
@bjorn3 Nevermind, I managed to fix the problem by not casting it int32
at all.
Last updated: Nov 22 2024 at 17:03 UTC