Struct wasi_common::table::Table[][src]

pub struct Table { /* fields omitted */ }

The Table type is designed to map u32 handles to resources. The table is now part of the public interface to a WasiCtx - it is reference counted so that it can be shared beyond a WasiCtx with other WASI proposals (e.g. wasi-crypto and wasi-nn) to manage their resources. Elements in the Table are Any typed.

The Table type is intended to model how the Interface Types concept of Resources is shaping up. Right now it is just an approximation.

Implementations

impl Table[src]

pub fn new() -> Self[src]

Create an empty table. New insertions will begin at 3, above stdio.

pub fn insert_at(&mut self, key: u32, a: Box<dyn Any>)[src]

Insert a resource at a certain index.

pub fn push(&mut self, a: Box<dyn Any>) -> Result<u32, Error>[src]

Insert a resource at the next available index.

pub fn contains_key(&self, key: u32) -> bool[src]

Check if the table has a resource at the given index.

pub fn is<T: Any + Sized>(&self, key: u32) -> bool[src]

Check if the resource at a given index can be downcast to a given type. Note: this will always fail if the resource is already borrowed.

pub fn get<T: Any + Sized>(&self, key: u32) -> Result<Ref<'_, T>, Error>[src]

Get an immutable reference to a resource of a given type at a given index. Multiple immutable references can be borrowed at any given time. Borrow failure results in a trapping error.

pub fn get_mut<T: Any + Sized>(&self, key: u32) -> Result<RefMut<'_, T>, Error>[src]

Get a mutable reference to a resource of a given type at a given index. Only one mutable reference can be borrowed at any given time. Borrow failure results in a trapping error.

pub fn delete(&mut self, key: u32) -> Option<Box<dyn Any>>[src]

Remove a resource at a given index from the table. Returns the resource if it was present.

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointee for T[src]

type Pointer = u32

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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