Skip to main content

Table

Struct Table 

Source
pub struct Table { /* private fields */ }
Expand description

A Wasm table entity.

Implementations§

Source§

impl Table

Source

pub fn new( ty: TableType, init: TypedRawRef, limiter: &mut ResourceLimiterRef<'_>, ) -> Result<Self, TableError>

Creates a new table entity with the given resizable limits.

§Errors

If init does not match the TableType element type.

Source

pub fn ty(&self) -> TableType

Returns the resizable limits of the table.

Source

pub fn dynamic_ty(&self) -> TableType

Returns the dynamic TableType of the Table.

§Note

This respects the current size of the Table as its minimum size and is useful for import subtyping checks.

Source

pub fn size(&self) -> u64

Returns the current size of the Table.

Source

pub fn grow( &mut self, delta: u64, init: TypedRawRef, fuel: Option<&mut Fuel>, limiter: &mut ResourceLimiterRef<'_>, ) -> Result<u64, TableError>

Grows the table by the given amount of elements.

Returns the old size of the table upon success.

§Note

This is an internal API that exists for efficiency purposes.

The newly added elements are initialized to the init RawRef.

§Errors

If the table is grown beyond its maximum limits.

Source

pub fn grow_raw( &mut self, delta: u64, init: RawRef, fuel: Option<&mut Fuel>, limiter: &mut ResourceLimiterRef<'_>, ) -> Result<u64, TableError>

Grows the table by the given amount of elements.

Returns the old size of the Table upon success.

§Note

This is an internal API that exists for efficiency purposes.

The newly added elements are initialized to the init RawRef.

§Errors

If the table is grown beyond its maximum limits.

Source

pub fn get(&self, index: u64) -> Option<TypedRawRef>

Returns the raw Table element reference at index.

Returns None if index is out of bounds.

§Note

This is a more efficient version of Table::get for internal use only.

Source

pub fn set(&mut self, index: u64, value: TypedRawRef) -> Result<(), TableError>

Sets the RawRef of the table at index.

§Errors

If index is out of bounds.

Source

pub fn set_raw(&mut self, index: u64, value: RawRef) -> Result<(), TableError>

Sets the RawRef of the Table at index.

§Errors

If index is out of bounds.

Source

pub fn init( &mut self, element: ElementSegmentRef<'_>, dst_index: u64, src_index: u32, len: u32, fuel: Option<&mut Fuel>, ) -> Result<(), TableError>

Initialize len elements from src_element[src_index..] into self[dst_index..].

§Errors

Returns an error if the range is out of bounds of either the source or destination tables.

§Panics

If the ElementSegment element type does not match the Table element type. Note: This is a panic instead of an error since it is asserted at Wasm validation time.

Source

pub fn copy( dst_table: &mut Self, dst_index: u64, src_table: &Self, src_index: u64, len: u64, fuel: Option<&mut Fuel>, ) -> Result<(), TableError>

Copy len elements from src_table[src_index..] into dst_table[dst_index..].

§Errors

Returns an error if the range is out of bounds of either the source or destination tables.

Source

pub fn copy_within( &mut self, dst_index: u64, src_index: u64, len: u64, fuel: Option<&mut Fuel>, ) -> Result<(), TableError>

Copy len elements from self[src_index..] into self[dst_index..].

§Errors

Returns an error if the range is out of bounds of the table.

Source

pub fn fill( &mut self, dst: u64, val: TypedRawRef, len: u64, fuel: Option<&mut Fuel>, ) -> Result<(), TableError>

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

§Note

This is an API for internal use only and exists for efficiency reasons.

§Errors
  • If the region to be filled is out of bounds for the table.
§Panics

If ctx does not own dst_table or src_table.

Source

pub fn fill_raw( &mut self, dst: u64, val: RawRef, len: u64, fuel: Option<&mut Fuel>, ) -> Result<(), TableError>

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

§Note

This is an API for internal use only and exists for efficiency reasons.

§Errors

If the region to be filled is out of bounds for the Table.

§Panics

If ctx does not own dst_table or src_table.

Trait Implementations§

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 Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnsafeUnpin 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 = !

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.