Wasmex.Memory.bytes_per_element
You're seeing just the function
bytes_per_element
, go back to Wasmex.Memory module for more information.
Link to this function
bytes_per_element(memory)
Specs
bytes_per_element(t()) :: pos_integer()
bytes_per_element(atom()) :: pos_integer()
Returns the number of bytes used to represent a unit in memory.
For the limited number of unit sizes the byte values are the following:
size | Bytes per element |
|----------|---|
| int8
| 1 |
| uint8
| 1 |
| int16
| 2 |
| uint16
| 2 |
| int32
| 4 |
| uint32
| 4 |
{:ok, memory} = Wasmex.Instance.memory(instance, :uint16, 0)
Wasmex.Memory.bytes_per_element(memory) # 2
Alternatively, the size atom can be given directly:
Wasmex.Memory.bytes_per_element(:uint32) # 4