Closed MaxGraey closed 5 years ago
It'd be nice if we could, however, the point of writing the hdk is to simplify memory management, given how holochain implements it... check out https://holochain.github.io/holochain-rust/writing_development_kit.html#the-development-kit-wasm-solution
Unfortunately I didn't find any mentions about memory layout for string representation. But according to this: https://github.com/holochain/holochain-rust/blob/8a69dc60020646342cccbb245d91ac9572f6f1e2/core/src/nucleus/ribosome/api/mod.rs#L157 Bytes should be encoded in utf8 (not sure about null terminating)
@MaxGraey just curious, how did you come upon this? Obviously you have a keen interest in holochain and holochain-rust. :)
Ahaha, not really. I'm just one of the AssemblyScript contributors.
Ah, gotcha. Coming at it from the other side. Well that's cool. I've been getting familiar with assemblyscript the last days, it's good to meet you!
You can simplify this: https://github.com/holochain/hdk-assemblyscript/blob/6ea42fd6766b5be95551d1f22d96369c1fe69217/main.ts#L18
if your host require UTF8 string of course. But according to debug api it seems and this it seems this exactly that case.
You could convert AssemblyScript's String to null terminated utf8 pointer. Such of similar stuff already done for EOS.io smart contracts and you can simply use
String#toUTF8()
method for that.