wasmedge_sys::instance::table

Struct 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>,

Source§

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>,

Source§

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.