wasmtime_component_linker_instance_add_resource function

  1. @Native<Pointer<wasmtime_error_t> Function(Pointer<wasmtime_component_linker_instance_t>, Pointer<wasm_byte_t>, Size, Pointer<wasmtime_component_resource_type_t>, wasmtime_component_resource_destructor_t, Pointer<Void>, Pointer<NativeFunction<Void Function(Pointer<Void>)>>)>(ffi.Pointer<wasmtime_component_linker_instance_t>, ffi.Pointer<ffi.Char>, ffi.Size, ffi.Pointer<wasmtime_component_resource_type_t>, wasmtime_component_resource_destructor_t, ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>)>()
Pointer<wasmtime_error_t> wasmtime_component_linker_instance_add_resource(
  1. Pointer<wasmtime_component_linker_instance_t> linker_instance,
  2. Pointer<wasm_byte_t> name,
  3. int name_len,
  4. Pointer<wasmtime_component_resource_type_t> resource,
  5. wasmtime_component_resource_destructor_t destructor,
  6. Pointer<Void> data,
  7. Pointer<NativeFunction<Void Function(Pointer<Void>)>> finalizer,
)

\brief Defines a new resource type within this instance.

This can be used to define a new resource type that the guest will be able to import. Here the resource is a type, often a host-defined type, which can be used to distinguish and definite different types of resources. A destruction callback is also specified via destructor which has private data data along with an optional finalizer for the data too.

\return on success NULL, otherwise an error

Implementation

@ffi.Native<
  ffi.Pointer<wasmtime_error_t> Function(
    ffi.Pointer<wasmtime_component_linker_instance_t>,
    ffi.Pointer<ffi.Char>,
    ffi.Size,
    ffi.Pointer<wasmtime_component_resource_type_t>,
    wasmtime_component_resource_destructor_t,
    ffi.Pointer<ffi.Void>,
    ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>,
  )
>()
external ffi.Pointer<wasmtime_error_t>
wasmtime_component_linker_instance_add_resource(
  ffi.Pointer<wasmtime_component_linker_instance_t> linker_instance,
  ffi.Pointer<ffi.Char> name,
  int name_len,
  ffi.Pointer<wasmtime_component_resource_type_t> resource,
  wasmtime_component_resource_destructor_t destructor,
  ffi.Pointer<ffi.Void> data,
  ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>
  finalizer,
);