polywrap_wasm.buffer module

This module provides a set of functions to read and write bytes from a memory buffer.

polywrap_wasm.buffer.mem_cpy(memory_pointer: Any, memory_length: int, value: bytearray, value_length: int, value_offset: int) None[source]

Copy bytearray from the given value to a memory buffer.

Parameters:
  • memory_pointer (BufferPointer) – The pointer to the memory buffer.

  • memory_length (int) – The length of the memory buffer.

  • value (bytearray) – The bytearray to copy.

  • value_length (int) – The length of the bytearray to copy.

  • value_offset (int) – The offset to start copying from.

polywrap_wasm.buffer.read_bytes(memory_pointer: Any, memory_length: int, offset: int | None = None, length: int | None = None) bytes[source]

Read bytes from a memory buffer.

Parameters:
  • memory_pointer (BufferPointer) – The pointer to the memory buffer.

  • memory_length (int) – The length of the memory buffer.

  • offset (Optional[int]) – The offset to start reading from.

  • length (Optional[int]) – The number of bytes to read.

polywrap_wasm.buffer.read_string(memory_pointer: Any, memory_length: int, offset: int, length: int) str[source]

Read a UTF-8 encoded string from a memory buffer.

Parameters:
  • memory_pointer (BufferPointer) – The pointer to the memory buffer.

  • memory_length (int) – The length of the memory buffer.

  • offset (int) – The offset to start reading from.

  • length (int) – The number of bytes to read.

polywrap_wasm.buffer.write_bytes(memory_pointer: Any, memory_length: int, value: bytes, value_offset: int) None[source]

Write bytes to a memory buffer.

Parameters:
  • memory_pointer (BufferPointer) – The pointer to the memory buffer.

  • memory_length (int) – The length of the memory buffer.

  • value (bytes) – The bytes to write.

  • value_offset (int) – The offset to start writing to.

polywrap_wasm.buffer.write_string(memory_pointer: Any, memory_length: int, value: str, value_offset: int) None[source]

Write a UTF-8 encoded string to a memory buffer.

Parameters:
  • memory_pointer (BufferPointer) – The pointer to the memory buffer.

  • memory_length (int) – The length of the memory buffer.

  • value (str) – The string to write.

  • value_offset (int) – The offset to start writing to.