wasmer-go
wasmer-go copied to clipboard
Write data into the initial memory
Thanks for proposing a new feature!
Motivation
Write custom data into the initial memory from Go side and let the functions in wasm can use it~
Can you elaborate or can you give an example of the kind of API you would like to get?
like wagon providing Process
struct to access memory easily. codes
Maybe can add more useful function, like growMemory()
, getAllocatedMemory()
, getUsedMemory()
(maybe unnecessary) and so on.
You have Instance.Memory
to access the memory. Then, you can call the Data()
method to get a slice over the memory, so that you can read or write things as you want.
Does it cover your initial need?
(I'll reopen the issue as soon as I receive a response :-))
Maybe we need an explore Write(bytes)
function. I think it's not a good design to modify the underlying bytes array directly.
In Write
function, we also need a mutex to implement parallel data reading&writing.
Are you suggesting to implement an io
interface, with Reader
and Writer
? Sounds a good idea to me.
Yeap, an io
interface is also a good idea~
The Instance.Memory seems to not exists anymore, in most recent version, what is the alternative?
It have GetMemory()
, but requires an name and requires to be exported, which is not the same as the old one.
I would like to put this example: https://github.com/tetratelabs/wazero/tree/main/examples/allocation/tinygo and implement it with wasmer-go
I try,but not success,can you give a example?
Hi 👋 I'd be interested in this too. It's supported by the python wasmer here: https://wasmerio.github.io/wasmer-python/api/wasmer/wasmer.html#Memory.uint8_view
This functionality would be useful when working with wasm modules which the wasmer user has no control over the module itself.
For example, this python library based on wasmer wraps OPA modules: https://github.com/a2d24/python-opa-wasm/blob/fb48a89e4b458628d59be58d159cae6aa4615007/opa_wasm/opa_wasm.py#L138 which have no exported functions for setting data.
I would like to put this example: https://github.com/tetratelabs/wazero/tree/main/examples/allocation/tinygo and implement it with wasmer-go
I try,but not success,can you give a example?
成功了吗