Struct wasmtime_wasi::preview2::table::Table
source · pub struct Table { /* private fields */ }
Expand description
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§
source§impl Table
impl Table
sourcepub fn push(&mut self, a: Box<dyn Any + Send + Sync>) -> Result<u32, TableError>
pub fn push(&mut self, a: Box<dyn Any + Send + Sync>) -> Result<u32, TableError>
Insert a resource at the next available index.
sourcepub fn contains_key(&self, key: u32) -> bool
pub fn contains_key(&self, key: u32) -> bool
Check if the table has a resource at the given index.
sourcepub fn is<T: Any + Sized>(&self, key: u32) -> bool
pub fn is<T: Any + Sized>(&self, key: u32) -> bool
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.
sourcepub fn get<T: Any + Sized>(&self, key: u32) -> Result<&T, TableError>
pub fn get<T: Any + Sized>(&self, key: u32) -> Result<&T, TableError>
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.
Trait Implementations§
source§impl TableStreamExt for Table
impl TableStreamExt for Table
fn push_input_stream( &mut self, istream: Box<dyn InputStream> ) -> Result<u32, TableError>
fn get_input_stream(&self, fd: u32) -> Result<&dyn InputStream, TableError>
fn get_input_stream_mut( &mut self, fd: u32 ) -> Result<&mut Box<dyn InputStream>, TableError>
fn push_output_stream( &mut self, ostream: Box<dyn OutputStream> ) -> Result<u32, TableError>
fn get_output_stream(&self, fd: u32) -> Result<&dyn OutputStream, TableError>
fn get_output_stream_mut( &mut self, fd: u32 ) -> Result<&mut Box<dyn OutputStream>, TableError>
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
source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where T: AsFilelike,
self
file descriptor.source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where T: AsFilelike,
source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where T: AsFilelike,
self
file descriptor. Read more