Table

Struct Table 

Source
pub struct Table(/* private fields */);
Expand description

Newtype wrapper around wasmi::Table.

Implementations§

Source§

impl Table

Source

pub fn new(inner: Table) -> Self

Create a wasm_runtime_layer::Table-compatible Table from a wasmi::Table.

Source

pub fn into_inner(self) -> Table

Consume a Table to obtain the inner wasmi::Table.

Methods from Deref<Target = Table>§

Source

pub fn ty(&self, ctx: impl AsContext) -> TableType

Returns the type and limits of the table.

§Panics

Panics if ctx does not own this Table.

Source

pub fn size(&self, ctx: impl AsContext) -> u64

Returns the current size of the Table.

§Panics

If ctx does not own this Table.

Source

pub fn grow( &self, ctx: impl AsContextMut, delta: u64, init: Val, ) -> Result<u64, TableError>

Grows the table by the given amount of elements.

Returns the old size of the Table upon success.

§Note

The newly added elements are initialized to the init Val.

§Errors
  • If the table is grown beyond its maximum limits.
  • If value does not match the Table element type.
§Panics

Panics if ctx does not own this Table.

Source

pub fn get(&self, ctx: impl AsContext, index: u64) -> Option<Val>

Returns the Table element value at index.

Returns None if index is out of bounds.

§Panics

Panics if ctx does not own this Table.

Source

pub fn set( &self, ctx: impl AsContextMut, index: u64, value: Val, ) -> Result<(), TableError>

Sets the Val of this Table at index.

§Errors
  • If index is out of bounds.
  • If value does not match the Table element type.
§Panics

Panics if ctx does not own this Table.

Source

pub fn fill( &self, ctx: impl AsContextMut, dst: u64, val: Val, len: u64, ) -> Result<(), TableError>

Fill table[dst..(dst + len)] with the given value.

§Errors
  • If val has a type mismatch with the element type of the Table.
  • If the region to be filled is out of bounds for the Table.
  • If val originates from a different Store than the Table.
§Panics

If ctx does not own dst_table or src_table.

Trait Implementations§

Source§

impl AsMut<Table> for Table

Source§

fn as_mut(&mut self) -> &mut Table

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsMut<Table> for Table

Source§

fn as_mut(&mut self) -> &mut Table

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<Table> for Table

Source§

fn as_ref(&self) -> &Table

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Table> for Table

Source§

fn as_ref(&self) -> &Table

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Table

Source§

fn clone(&self) -> Table

Returns a duplicate 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 Deref for Table

Source§

type Target = Table

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Table

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl From<Table> for Table

Source§

fn from(inner: Table) -> Self

Converts to this type from the input type.
Source§

impl From<Table> for Table

Source§

fn from(wrapper: Table) -> Self

Converts to this type from the input type.
Source§

impl RefCast for Table

Source§

type From = Table

Source§

fn ref_cast(_from: &Self::From) -> &Self

Source§

fn ref_cast_mut(_from: &mut Self::From) -> &mut Self

Source§

impl WasmTable<Engine> for Table

Source§

fn new( ctx: impl AsContextMut<Engine>, ty: TableType, init: Value<Engine>, ) -> Result<Self>

Creates a new table to the store.
Source§

fn ty(&self, ctx: impl AsContext<Engine>) -> TableType

Returns the type and limits of the table.
Source§

fn size(&self, ctx: impl AsContext<Engine>) -> u32

Returns the current size of the table.
Source§

fn grow( &self, ctx: impl AsContextMut<Engine>, delta: u32, init: Value<Engine>, ) -> Result<u32>

Grows the table by the given amount of elements.
Source§

fn get( &self, ctx: impl AsContextMut<Engine>, index: u32, ) -> Option<Value<Engine>>

Returns the table element value at index.
Source§

fn set( &self, ctx: impl AsContextMut<Engine>, index: u32, value: Value<Engine>, ) -> Result<()>

Sets the value of this table at index.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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