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 insert_at<T: Any + Send + Sync>(&self, key: u32, a: Arc<T>)
pub fn insert_at<T: Any + Send + Sync>(&self, key: u32, a: Arc<T>)
Insert a resource at a certain index.
sourcepub fn push<T: Any + Send + Sync>(&self, a: Arc<T>) -> Result<u32, Error>
pub fn push<T: Any + Send + Sync>(&self, a: Arc<T>) -> Result<u32, Error>
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 + Send + Sync + Sized>(
&self,
key: u32,
) -> Result<Arc<T>, Error>
pub fn get<T: Any + Send + Sync + Sized>( &self, key: u32, ) -> Result<Arc<T>, Error>
Get an Arc reference to a resource of a given type at a given index. Multiple immutable references can be borrowed at any given time.
sourcepub fn get_mut<T: Any>(&mut self, key: u32) -> Result<&mut T, Error>
pub fn get_mut<T: Any>(&mut self, key: u32) -> Result<&mut T, Error>
Get a mutable reference to a resource of a given type at a given index. Only one such reference can be borrowed at any given time.
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> 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
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§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.§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§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more