Struct wasi_common::table::Table [−][src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointee for T
[src]
type Pointer = u32
pub fn debug(
pointer: <T as Pointee>::Pointer,
f: &mut Formatter<'_>
) -> Result<(), Error>
[src]
pointer: <T as Pointee>::Pointer,
f: &mut Formatter<'_>
) -> Result<(), Error>
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,