#[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).
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Resource<T>
impl<T> RefUnwindSafe for Resource<T>
impl<T> Send for Resource<T>
impl<T> Sync for Resource<T>
impl<T> Unpin for Resource<T>
impl<T> UnwindSafe for Resource<T>
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
Mutably borrows from an owned value. Read more