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()
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
Link to this function
bytes_per_element(memory, size, offset)
Specs
bytes_per_element(t(), atom(), non_neg_integer()) :: pos_integer()
Same as bytes_per_element/1 except the unit size
and offset given at memory creation are overwritten by the given values.
{:ok, memory} = Wasmex.Instance.memory(instance)
Wasmex.Memory.bytes_per_element(memory, :uint32, 0) # 4