pub struct Table(/* private fields */);Expand description
A WebAssembly table instance.
The Table struct is an array-like structure representing a WebAssembly Table,
which stores function references.
A table created by the host or in WebAssembly code will be accessible and mutable from both host and WebAssembly.
Spec: https://webassembly.github.io/spec/core/exec/runtime.html#table-instances
Implementations§
Source§impl Table
impl Table
Sourcepub fn new(
store: &mut impl AsStoreMut,
ty: TableType,
init: Value,
) -> Result<Self, RuntimeError>
pub fn new( store: &mut impl AsStoreMut, ty: TableType, init: Value, ) -> Result<Self, RuntimeError>
Creates a new Table with the provided TableType definition.
All the elements in the table will be set to the init value.
This function will construct the Table using the store BaseTunables.
Sourcepub fn ty(&self, store: &impl AsStoreRef) -> TableType
pub fn ty(&self, store: &impl AsStoreRef) -> TableType
Returns the TableType of the Table.
Sourcepub fn get(&self, store: &mut impl AsStoreMut, index: u32) -> Option<Value>
pub fn get(&self, store: &mut impl AsStoreMut, index: u32) -> Option<Value>
Retrieves an element of the table at the provided index.
Sourcepub fn set(
&self,
store: &mut impl AsStoreMut,
index: u32,
val: Value,
) -> Result<(), RuntimeError>
pub fn set( &self, store: &mut impl AsStoreMut, index: u32, val: Value, ) -> Result<(), RuntimeError>
Sets an element val in the Table at the provided index.
Sourcepub fn size(&self, store: &impl AsStoreRef) -> u32
pub fn size(&self, store: &impl AsStoreRef) -> u32
Retrieves the size of the Table (in elements)
Sourcepub fn grow(
&self,
store: &mut impl AsStoreMut,
delta: u32,
init: Value,
) -> Result<u32, RuntimeError>
pub fn grow( &self, store: &mut impl AsStoreMut, delta: u32, init: Value, ) -> Result<u32, RuntimeError>
Grows the size of the Table by delta, initializating
the elements with the provided init value.
It returns the previous size of the Table in case is able
to grow the Table successfully.
§Errors
Returns an error if the delta is out of bounds for the table.
Sourcepub fn copy(
store: &mut impl AsStoreMut,
dst_table: &Self,
dst_index: u32,
src_table: &Self,
src_index: u32,
len: u32,
) -> Result<(), RuntimeError>
pub fn copy( store: &mut impl AsStoreMut, dst_table: &Self, dst_index: u32, src_table: &Self, src_index: u32, len: u32, ) -> Result<(), RuntimeError>
Copies the len elements of src_table starting at src_index
to the destination table dst_table at index dst_index.
§Errors
Returns an error if the range is out of bounds of either the source or destination tables.
Sourcepub fn is_from_store(&self, store: &impl AsStoreRef) -> bool
pub fn is_from_store(&self, store: &impl AsStoreRef) -> bool
Checks whether this Table can be used with the given context.
Trait Implementations§
Source§impl<'a> Exportable<'a> for Table
impl<'a> Exportable<'a> for Table
Source§fn get_self_from_extern(_extern: &'a Extern) -> Result<&'a Self, ExportError>
fn get_self_from_extern(_extern: &'a Extern) -> Result<&'a Self, ExportError>
Instance by name.impl Eq for Table
impl StructuralPartialEq for Table
Auto Trait Implementations§
impl Freeze for Table
impl RefUnwindSafe for Table
impl Send for Table
impl Sync for Table
impl Unpin for Table
impl UnwindSafe for Table
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more