Struct wasmtime_runtime::Table
source · [−]pub struct Table { /* private fields */ }
Expand description
A table instance.
Implementations
sourceimpl Table
impl Table
sourcepub fn new(plan: &TablePlan) -> Self
pub fn new(plan: &TablePlan) -> Self
Create a new table instance with specified minimum and maximum number of elements.
sourcepub fn element_type(&self) -> TableElementType
pub fn element_type(&self) -> TableElementType
Returns the type of the elements in this table.
sourcepub fn fill(&self, dst: u32, val: TableElement, len: u32) -> Result<(), Trap>
pub fn fill(&self, dst: u32, val: TableElement, len: u32) -> Result<(), Trap>
Fill table[dst..dst + len]
with val
.
Returns a trap error on out-of-bounds accesses.
sourcepub unsafe fn grow(&self, delta: u32, init_value: TableElement) -> Option<u32>
pub unsafe fn grow(&self, delta: u32, init_value: TableElement) -> Option<u32>
Grow table by the specified amount of elements.
Returns the previous size of the table if growth is successful.
Returns None
if table can’t be grown by the specified amount of
elements, or if the init_value
is the wrong kind of table element.
Unsafety
Resizing the table can reallocate its internal elements buffer. This
table’s instance’s VMContext
has raw pointers to the elements buffer
that are used by Wasm, and they need to be fixed up before we call into
Wasm again. Failure to do so will result in use-after-free inside Wasm.
Generally, prefer using InstanceHandle::table_grow
, which encapsulates
this unsafety.
sourcepub fn get(&self, index: u32) -> Option<TableElement>
pub fn get(&self, index: u32) -> Option<TableElement>
Get reference to the specified element.
Returns None
if the index is out of bounds.
sourcepub fn set(&self, index: u32, elem: TableElement) -> Result<(), ()>
pub fn set(&self, index: u32, elem: TableElement) -> Result<(), ()>
Set reference to the specified element.
Errors
Returns an error if index
is out of bounds or if this table type does
not match the element type.
sourcepub fn copy(
dst_table: &Self,
src_table: &Self,
dst_index: u32,
src_index: u32,
len: u32
) -> Result<(), Trap>
pub fn copy(
dst_table: &Self,
src_table: &Self,
dst_index: u32,
src_index: u32,
len: u32
) -> Result<(), Trap>
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.
sourcepub fn vmtable(&self) -> VMTableDefinition
pub fn vmtable(&self) -> VMTableDefinition
Return a VMTableDefinition
for exposing the table to compiled wasm code.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Table
impl !Send for Table
impl !Sync for Table
impl Unpin for Table
impl !UnwindSafe for Table
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more