barrel_design_module (barrel_design v0.1.0)

View Source

Admission checks for a guest module (ABI barrel_v1).

Linking alone would accept an import of the right name with any signature, since a host fun takes the signature the guest declares. These checks run before any instantiation, on the decoded module:

  • imports: only barrel_v1.field(i32, i32, i32) -> i32, barrel_v1.emit(i32, i32, i32, i32), barrel_v1.input(i32, i32) -> i32 and barrel_v1.output(i32, i32), each at most once;
  • the export checked has its role's type: a map takes and returns nothing, a reducer takes the rereduce flag (i32) and returns nothing. One module may export both;
  • exactly one memory, defined in the module, 32-bit, unshared, with a declared maximum within the view's page limit;
  • no start function, no imported memory, table or global, tables bounded, no GC types or exception tags;
  • no SIMD, atomics, exception or GC instructions.

Summary

Functions

Check a decoded module (from bytes or inline WAT).

Check portable bytes against their declared digest, then their contents (see check/3).

Functions

check(Module, Id, Opts)

-spec check(tuple(),
            term(),
            #{export := binary(), max_memory_pages := pos_integer(), role => map | reduce}) ->
               {ok, map()} | {error, term()}.

Check a decoded module (from bytes or inline WAT).

check_bytes(Bytes, Digest, Opts)

-spec check_bytes(binary(),
                  binary(),
                  #{export := binary(), max_memory_pages := pos_integer(), role => map | reduce}) ->
                     {ok, map()} | {error, term()}.

Check portable bytes against their declared digest, then their contents (see check/3).