pub struct Handle<T: HandleType> { /* private fields */ }
Expand description

A type for handles to resources that appear in exported functions.

This type is used as Handle<T> for argument types and return values of exported functions when exposing a Rust-defined resource. A Handle<T> represents an owned reference count on the interface-types-managed resource. It’s similar to an Rc<T> in Rust. Internally a Handle<T> can provide access to &T when T is defined in the current module.

Implementations

Creates a new handle around the specified value.

Note that the lifetime of T will afterwards be managed by the interface types runtime. The host may hold references to T that wasm isn’t necessarily aware of, preventing its destruction. Nevertheless though the Drop for T implementation will still be run when there are no more references to T.

Consumes a handle and returns the underlying raw wasm i32 descriptor.

Note that this, if used improperly, will leak the resource T. This generally should be avoided unless you’re calling raw ABI bindings and managing the lifetime manually.

Returns the raw underlying handle value for this handle.

This typically isn’t necessary to interact with, but can be useful when interacting with raw ABI bindings.

Unsafely assumes that the given integer descriptor is a handle for T.

This is unsafe because no validation is performed to ensure that val is actually a valid descriptor for T.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
Executes the destructor for this type. Read more
Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.