Struct wasmedge_sys::Table

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

A WasmEdge Table defines a WebAssembly table instance described by its type. A table is an array-like structure and stores function references.

This example shows how to use Table to store and retrieve function references.

Implementations§

source§

impl Table

source

pub fn create(ty: TableType) -> WasmEdgeResult<Self>

Creates a new Table to be associated with the given element type and the size.

§Arguments
  • ty specifies the type of the new Table.
§Error
  • If fail to create the table instance, then WasmEdgeError::Table(TableError::Create)(crate::error::TableError) is returned.
source

pub fn ty(&self) -> WasmEdgeResult<TableType>

Returns the [TableType] of the Table.

§Error

If fail to get type, then an error is returned.

source

pub fn get_data(&self, idx: u32) -> WasmEdgeResult<WasmValue>

Returns the element value at a specific position in the Table.

§Arguments
  • idx specifies the position in the Table, at which the WasmValue is returned.
§Error

If fail to get the data, then an error is returned.

source

pub fn set_data(&mut self, data: WasmValue, idx: u32) -> WasmEdgeResult<()>

Sets a new element value at a specific position in the Table.

§Arguments
  • data specifies the new data.

  • idx specifies the position of the new data to be stored in the Table.

§Error

If fail to set data, then an error is returned.

source

pub fn capacity(&self) -> usize

Returns the capacity of the Table.

source

pub fn grow(&mut self, size: u32) -> WasmEdgeResult<()>

Increases the capacity of the Table.

After growing, the new capacity must be in the range defined by limit when the table is created.

§Argument
  • size specifies the size to be added to the Table.
§Error

If fail to increase the size of the Table, then an error is returned.

source

pub unsafe fn as_ptr(&self) -> *const WasmEdge_TableInstanceContext

§Safety

The lifetime of the returned pointer must not exceed that of the object itself.

source

pub unsafe fn from_raw(ptr: *mut WasmEdge_TableInstanceContext) -> Self

§Safety

This function will take over the lifetime management of ptr, so do not call ffi::WasmEdge_TableInstanceDelete on ptr after this.

Trait Implementations§

source§

impl Debug for Table

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Table

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.