Class: Wasmtime::Component::Func

Inherits:
Object
  • Object
show all
Defined in:
ext/src/ruby_api/component/func.rs

Overview

Represents a WebAssembly component Function

Component model types conversion

Here’s how component model types map to Ruby objects:

bool

Ruby true or false, no automatic conversion happens.

s8, u8, s16, u16, etc.

Ruby Integer. Overflows raise.

f32, f64

Ruby Float.

string

Ruby String. Exception will be raised if the string is not valid UTF-8.

list<T>

Ruby Array.

tuple

Ruby Array of the same size of tuple. Example: tuple<T, U> would be converted to [T, U].

record

Ruby Hash where field names are Strings.

result<O, E>

Result instance. When converting a result branch of the none type, the Result’s value MUST be nil.

Examples of none type in a result: unparametrized result, result<O>, result<_, E>.

option<T>

nil is mapped to None, anything else is mapped to Some(T).

flags

Ruby Array of Strings.

enum

Ruby String. Exception will be raised of the String is not a valid enum value.

variant

Variant instance wrapping the variant’s name and optionally its value. Exception will be raised for:

resource (own<T> or borrow<T>)

Not yet supported.

Instance Method Summary collapse

Instance Method Details

#call(*args) ⇒ Object

Calls a Wasm component model function.

Parameters:

  • args (Array<Object>)

    the function’s arguments as per its Wasm definition

Returns:

  • (Object)

    the function’s return value as per its Wasm definition

See Also:



79
80
81
# File 'ext/src/ruby_api/component/func.rs', line 79

pub fn call(&self, args: &[Value]) -> Result<Value, Error> {
    Func::invoke(self.store, &self.inner, args)
}