Trait ComponentType
pub unsafe trait ComponentType { }
Expand description
A trait representing types which can be passed to and read from components with the canonical ABI.
This trait is implemented for Rust types which can be communicated to
components. The Func::typed
and TypedFunc
Rust items are the main
consumers of this trait.
Supported Rust types include:
Component Model Type | Rust Type |
---|---|
{s,u}{8,16,32,64} | {i,u}{8,16,32,64} |
f{32,64} | f{32,64} |
bool | bool |
char | char |
tuple<A, B> | (A, B) |
option<T> | Option<T> |
result | Result<(), ()> |
result<T> | Result<T, ()> |
result<_, E> | Result<(), E> |
result<T, E> | Result<T, E> |
string | String , &str , or WasmStr |
list<T> | Vec<T> , &[T] , or WasmList |
own<T> , borrow<T> | Resource<T> or ResourceAny |
record | #[derive(ComponentType)] |
variant | #[derive(ComponentType)] |
enum | #[derive(ComponentType)] |
flags | flags! |
Rust standard library pointers such as &T
, Box<T>
, Rc<T>
, and Arc<T>
additionally represent whatever type T
represents in the component model.
Note that types such as record
, variant
, enum
, and flags
are
generated by the embedder at compile time. These macros derive
implementation of this trait for custom types to map to custom types in the
component model. Note that for record
, variant
, enum
, and flags
those types are often generated by the
bindgen!
macro from WIT definitions.
Types that implement ComponentType
are used for Params
and Return
in TypedFunc
and Func::typed
.
The contents of this trait are hidden as it’s intended to be an implementation detail of Wasmtime. The contents of this trait are not covered by Wasmtime’s stability guarantees.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.