class

Wasm3::Memory

Inherits Reference < Object

A bounds-checked view over a runtime's linear memory.

The view asks Wasm3 for the memory pointer on each operation, so it remains valid when the guest grows memory. Keep a Memory object only while its Runtime is alive.

Instance methods

[](offset : Int) : UInt8
Source
[]=(offset : Int, value : UInt8)
Source
bytes

Returns a zero-copy slice. The slice must not be retained across guest memory growth; use read_bytes for an owned copy.

Source
empty?
Source
index
Source
io(offset : Int = 0, length : Int | Nil = nil, writable : Bool = true) : MemoryIO

Returns an IO over [offset, offset + length). The IO is fixed-size: a write past its end raises IO::Error instead of growing guest memory.

Source
read_bytes(offset : Int, length : Int) : Bytes
Source
read_c_string(offset : Int = 0, max_length : Int | Nil = nil) : String
Source
read_into(offset : Int, destination : Bytes) : Nil

Copies memory into +destination+. This is public so callers can avoid an intermediate allocation when decoding a guest buffer.

Source
read_string(offset : Int, length : Int) : String
Source
runtime
Source
size
Source
to_io(offset : Int = 0, length : Int | Nil = nil, writable : Bool = true) : MemoryIO
Source
write(offset : Int, source : Bytes) : Nil
Source
write(offset : Int, source : String) : Nil
Source
write_string(offset : Int, source : String, null_terminated : Bool = false) : Nil
Source