Class: Wasmtime::Extern

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

Overview

An external item to a WebAssembly module, or a list of what can possibly be exported from a Wasm module.

Instance Method Summary collapse

Instance Method Details

#to_funcFunc

Returns the exported function or raises a ‘ConversionError` when the export is not a function.

Returns:

  • (Func)

    The exported function.



55
56
57
58
59
60
# File 'ext/src/ruby_api/externals.rs', line 55

pub fn to_func(rb_self: Obj<Self>) -> Result<Value, Error> {
    match rb_self.get() {
        Extern::Func(f) => Ok(**f),
        _ => conversion_err!(Self::inner_class(rb_self), Func::class()),
    }
}

#to_globalGlobal

Returns the exported global or raises a ‘ConversionError` when the export is not a global.

Returns:

  • (Global)

    The exported global.



65
66
67
68
69
70
# File 'ext/src/ruby_api/externals.rs', line 65

pub fn to_global(rb_self: Obj<Self>) -> Result<Value, Error> {
    match rb_self.get() {
        Extern::Global(g) => Ok(**g),
        _ => conversion_err!(Self::inner_class(rb_self), Global::class()),
    }
}

#to_memoryMemory

Returns the exported memory or raises a ‘ConversionError` when the export is not a memory.

Returns:

  • (Memory)

    The exported memory.



76
77
78
79
80
81
# File 'ext/src/ruby_api/externals.rs', line 76

pub fn to_memory(rb_self: Obj<Self>) -> Result<Value, Error> {
    match rb_self.get() {
        Extern::Memory(m) => Ok(**m),
        _ => conversion_err!(Self::inner_class(rb_self), Memory::class()),
    }
}

#to_tableTable

Returns the exported table or raises a ‘ConversionError` when the export is not a table.

Returns:

  • (Table)

    The exported table.



86
87
88
89
90
91
# File 'ext/src/ruby_api/externals.rs', line 86

pub fn to_table(rb_self: Obj<Self>) -> Result<Value, Error> {
    match rb_self.get() {
        Extern::Table(t) => Ok(**t),
        _ => conversion_err!(Self::inner_class(rb_self), Table::class()),
    }
}