Struct wasmedge_sdk::Table

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

Defines a table storing the references to host functions or external objects.

Implementations§

source§

impl Table

source

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

Creates a new wasm table instance with the given type.

Argument
  • ty - The type of the table instance to be created.
Error
  • If fail to create the table instance, then WasmEdgeError::Table(TableError::Create)(crate::error::TableError) is returned.
source

pub fn name(&self) -> Option<&str>

Returns the exported name of this table instance.

Notice that this field is meaningful only if this table is used as an exported instance.

source

pub fn mod_name(&self) -> Option<&str>

Returns the name of the module instance from which this table instance exports.

Notice that this field is meaningful only if this table is used as an exported instance.

source

pub fn ty(&self) -> &TableType

Returns a reference to the type of this table.

source

pub fn size(&self) -> u32

Returns the size of this Table.

source

pub fn grow(&mut self, delta: u32, init: Option<Val>) -> WasmEdgeResult<u32>

Grows the size of this table by delta, initializing the elements with the provided init value if init is given. Returns the previous size of the table.

Arguments
  • delta - The number of elements to grow the table instance by.

  • init - The value to initialize the new table slots with.

Error

If fail to grow the table, then an error is returned.

source

pub fn get(&self, index: u32) -> WasmEdgeResult<Val>

Returns the table element at the index.

Argument
  • index - the index of the table element to get.
Error

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

source

pub fn set(&mut self, index: u32, data: Val) -> WasmEdgeResult<()>

Stores the data at the index of this table.

Arguments
  • index - the index of the table element to store.

  • data - the data to store at the index of this table.

Error

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

Trait Implementations§

source§

impl Clone for Table

source§

fn clone(&self) -> Table

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Table

source§

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

Formats the value using the given formatter. Read more

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V