Struct wasi_common::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
sourceimpl Table
impl Table
sourcepub fn insert_at(&mut self, key: u32, a: Box<dyn Any + Send + Sync>)
pub fn insert_at(&mut self, key: u32, a: Box<dyn Any + Send + Sync>)
Insert a resource at a certain index.
sourcepub fn push(&mut self, a: Box<dyn Any + Send + Sync>) -> Result<u32, Error>
pub fn push(&mut self, a: Box<dyn Any + Send + Sync>) -> 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 + Sized>(&self, key: u32) -> Result<&T, Error>
pub fn get<T: Any + Sized>(&self, key: u32) -> Result<&T, Error>
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.
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more