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.



132
133
134
135
136
137
# File 'ext/src/ruby_api/externals.rs', line 132

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

#to_globalGlobal

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

Returns:

  • (Global)

    The exported global.



142
143
144
145
146
147
# File 'ext/src/ruby_api/externals.rs', line 142

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

#to_memoryMemory

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

Returns:

  • (Memory)

    The exported memory.



153
154
155
156
157
158
# File 'ext/src/ruby_api/externals.rs', line 153

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

#to_tableTable

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

Returns:

  • (Table)

    The exported table.



163
164
165
166
167
168
# File 'ext/src/ruby_api/externals.rs', line 163

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