Struct wiggle::wasmtime_crate::Table [−][src]
#[repr(transparent)]pub struct Table(_);
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 reference type values rather than bytes. One of
the most common usages of a table is a function table for wasm modules (a
funcref
table), where each element has the ValType::FuncRef
type.
A Table
“belongs” to the store that it was originally created within
(either via Table::new
or via instantiating a Module
). Operations
on a Table
only work with the store it belongs to, and if another store
is passed in by accident then methods will panic.
Implementations
Creates a new Table
with the given parameters.
store
- the owner of the resultingTable
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,
or if init
does not belong to the store
provided.
Examples
let engine = Engine::default();
let mut store = Store::new(&engine, ());
let ty = TableType::new(ValType::FuncRef, 2, None);
let table = Table::new(&mut store, ty, Val::FuncRef(None))?;
let module = Module::new(
&engine,
"(module
(table (import \"\" \"\") 2 funcref)
(func $f (result i32)
i32.const 10)
(elem (i32.const 0) (func $f))
)"
)?;
let instance = Instance::new(&mut store, &module, &[table.into()])?;
// ...
Returns the underlying type of this table, including its element type as well as the maximum/minimum lower bounds.
Panics
Panics if store
does not own this table.
Returns the table element value at index
.
Returns None
if index
is out of bounds.
Panics
Panics if store
does not own 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 or if init
does not belong to
store
.
Panics
Panics if store
does not own this table.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Table
impl UnwindSafe for Table
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more