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