Struct wasmedge_sys::Table
source · pub struct Table { /* private fields */ }
Expand description
Implementations§
source§impl Table
impl Table
sourcepub fn create(ty: &TableType) -> WasmEdgeResult<Self>
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.
Example
use wasmedge_sys::{TableType, Table};
use wasmedge_types::RefType;
// create a TableType instance
let ty = TableType::create(RefType::FuncRef, 10, Some(20)).expect("fail to create a TableType");
// create a Table instance
let table = Table::create(&ty).expect("fail to create a Table");
sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the capacity of the Table.
Example
use wasmedge_sys::{TableType, Table};
use wasmedge_types::RefType;
// create a TableType instance and a Table
let ty = TableType::create(RefType::FuncRef, 10, Some(20)).expect("fail to create a TableType");
let table = Table::create(&ty).expect("fail to create a Table");
// check capacity
assert_eq!(table.capacity(), 10);
sourcepub fn as_ptr(&self) -> *const WasmEdge_TableInstanceContext
pub fn as_ptr(&self) -> *const WasmEdge_TableInstanceContext
Provides a raw pointer to the inner table context.