Struct linera_wasmer::Table
source · 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.source§impl PartialEq for Table
impl PartialEq for Table
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
§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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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