#[repr(C)]pub struct Resource<T> { /* private fields */ }
Expand description
Host resource exposed to WASM.
Internally, a resource is just an index into the externref
s table; thus, it is completely
valid to store Resource
s on heap (in a Vec
, thread-local storage, etc.). The type param
can be used for type safety.
Implementations§
source§impl Resource<()>
impl Resource<()>
sourcepub unsafe fn downcast_unchecked<T>(self) -> Resource<T>
pub unsafe fn downcast_unchecked<T>(self) -> Resource<T>
Downcasts this generic resource to a specific type.
Safety
No checks are performed that the resource actually encapsulates what is meant
by Resource<T>
. It is up to the caller to check this beforehand (e.g., by calling
a WASM import taking &Resource<()>
and returning an app-specific resource kind).