Struct wasmedge_sys::instance::table::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 ty(&self) -> WasmEdgeResult<TableType>
pub fn ty(&self) -> WasmEdgeResult<TableType>
sourcepub fn get_data(&self, idx: u32) -> WasmEdgeResult<WasmValue>
pub fn get_data(&self, idx: u32) -> WasmEdgeResult<WasmValue>
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 grow(&mut self, size: u32) -> WasmEdgeResult<()>
pub fn grow(&mut self, size: u32) -> WasmEdgeResult<()>
sourcepub fn as_ptr(&self) -> *const WasmEdge_TableInstanceContext
Available on crate feature ffi
only.
pub fn as_ptr(&self) -> *const WasmEdge_TableInstanceContext
ffi
only.Provides a raw pointer to the inner table context.
Trait Implementations§
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> 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
Mutably borrows from an owned value. Read more