|
Wasmtime
|
Representation of a compiled WebAssembly component. More...
#include <component.hh>
Public Member Functions | |
| Component (const Component &other) | |
| Copies another component into this one. | |
| Component & | operator= (const Component &other) |
| Copies another component into this one. | |
| Component (Component &&other)=default | |
| Moves resources from another component into this one. | |
| Component & | operator= (Component &&other)=default |
| Moves resources from another component into this one. | |
| const wasmtime_component_t * | capi () const |
| Returns the underlying C API pointer. | |
| wasmtime_component_t * | capi () |
| Returns the underlying C API pointer. | |
| Result< std::vector< uint8_t > > | serialize () const |
| Serializes this component to a list of bytes. More... | |
| std::optional< ExportIndex > | export_index (ExportIndex *instance, std::string_view name) |
Returns the export index for the export named name in this component. More... | |
Static Public Member Functions | |
| static Result< Component > | compile (Engine &engine, std::string_view wat) |
| Compiles a component from the WebAssembly text format. More... | |
| static Result< Component > | compile (Engine &engine, Span< uint8_t > wasm) |
| Compiles a component from the WebAssembly binary format. More... | |
| static Result< Component > | deserialize (Engine &engine, Span< uint8_t > wasm) |
Deserializes a previous list of bytes created with serialize. More... | |
| static Result< Component > | deserialize_file (Engine &engine, const std::string &path) |
| Deserializes a component from an on-disk file. More... | |
Representation of a compiled WebAssembly component.
|
inlinestatic |
Compiles a component from the WebAssembly binary format.
This function compiles the provided WebAssembly binary specified by wasm within the compilation settings configured by engine. This method is synchronous and will not return until the component has finished compiling.
This function can fail if the WebAssembly binary is invalid or doesn't validate (or similar). Note that this API does not compile WebAssembly modules, which is done with Module instead of Component.
|
inlinestatic |
Compiles a component from the WebAssembly text format.
This function will automatically use wat2wasm on the input and then delegate to the compile function.
|
inlinestatic |
Deserializes a previous list of bytes created with serialize.
This function is intended to be much faster than compile where it uses the artifacts of a previous compilation to quickly create an in-memory component ready for instantiation.
It is not safe to pass arbitrary input to this function, it is only safe to pass in output from previous calls to serialize. For more information see the Rust documentation - https://docs.wasmtime.dev/api/wasmtime/struct.Module.html#method.deserialize
|
inlinestatic |
Deserializes a component from an on-disk file.
This function is the same as deserialize except that it reads the data for the serialized component from the path on disk. This can be faster than the alternative which may require copying the data around.
It is not safe to pass arbitrary input to this function, it is only safe to pass in output from previous calls to serialize. For more information see the Rust documentation - https://docs.wasmtime.dev/api/wasmtime/struct.Module.html#method.deserialize
|
inline |
Returns the export index for the export named name in this component.
The instance argument is an optionally provided index which is the instance under which the name should be looked up.
|
inline |
Serializes this component to a list of bytes.
The returned bytes can then be used to later pass to deserialize to quickly recreate this component in a different process perhaps.