Class: Wasmtime::Caller
- Inherits:
-
Object
- Object
- Wasmtime::Caller
- Defined in:
- ext/src/ruby_api/caller.rs
Overview
Represents the Caller’s context within a Func execution. An instance of Caller is sent as the first parameter to Func’s implementation (the block argument in Func.new).
Instance Method Summary collapse
- #export(name) ⇒ Object
-
#get_fuel ⇒ Integer
Returns the amount of fuel in the Store.
-
#set_fuel(fuel) ⇒ Object
Sets fuel to the Store.
-
#store_data ⇒ Object
Returns the store’s data.
Instance Method Details
#export(name) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'ext/src/ruby_api/caller.rs', line 68
pub fn export(rb_self: Obj<Caller<'a>>, name: RString) -> Result<Option<Extern<'a>>, Error> {
let inner = rb_self.handle.get_mut()?;
if let Some(export) = inner.get_export(unsafe { name.as_str() }?) {
export.wrap_wasmtime_type(rb_self.into()).map(Some)
} else {
Ok(None)
}
}
|
#get_fuel ⇒ Integer
Returns the amount of fuel in the Store.
81 82 83 84 85 86 |
# File 'ext/src/ruby_api/caller.rs', line 81
pub fn get_fuel(&self) -> Result<u64, Error> {
self.handle
.get()
.map(|c| c.get_fuel())?
.map_err(|e| error!("{}", e))
}
|
#set_fuel(fuel) ⇒ Object
Sets fuel to the Store.
91 92 93 94 95 96 97 |
# File 'ext/src/ruby_api/caller.rs', line 91
pub fn set_fuel(&self, fuel: u64) -> Result<(), Error> {
self.handle
.get_mut()
.and_then(|c| c.set_fuel(fuel).map_err(|e| error!("{}", e)))?;
Ok(())
}
|
#store_data ⇒ Object
Returns the store’s data. Akin to Store#data.
61 62 63 |
# File 'ext/src/ruby_api/caller.rs', line 61
pub fn store_data(&self) -> Result<Value, Error> {
self.context().map(|ctx| ctx.data().user_data())
}
|