pub struct Table { /* private fields */ }
Expand description

A WebAssembly table, or an array of values.

Like Memory a table is an indexed array of values, but unlike Memory it’s an array of WebAssembly values rather than bytes. One of the most common usages of a table is a function table for wasm modules, where each element has the Func type.

Tables, like globals, are not threadsafe and can only be used on one thread. Tables can be grown in size and each element can be read/written.

Table and Clone

Tables are internally reference counted so you can clone a Table. The cloning process only performs a shallow clone, so two cloned Table instances are equivalent in their functionality.

Implementations

Creates a new Table with the given parameters.

  • store - a global cache to store information in
  • ty - the type of this table, containing both the element type as well as the initial size and maximum size, if any.
  • init - the initial value to fill all table entries with, if the table starts with an initial size.
Errors

Returns an error if init does not match the element type of the table.

Returns the underlying type of this table, including its element type as well as the maximum/minimum lower bounds.

Returns the table element value at index.

Returns None if index is out of bounds.

Writes the val provided into index within this table.

Errors

Returns an error if index is out of bounds or if val does not have the right type to be stored in this table.

Returns the current size of this table.

Grows the size of this table by delta more elements, initialization all new elements to init.

Returns the previous size of this table if successful.

Errors

Returns an error if the table cannot be grown by delta, for example if it would cause the table to exceed its maximum size. Also returns an error if init is not of the right type.

Copy len elements from src_table[src_index..] into dst_table[dst_index..].

Errors

Returns an error if the range is out of bounds of either the source or destination tables.

Fill table[dst..(dst + len)] with the given value.

Errors

Returns an error if

  • val is not of the same type as this table’s element type,

  • the region to be filled is out of bounds, or

  • val comes from a different Store from this table.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.