Class: Kobako::Runtime
- Inherits:
-
Object
- Object
- Kobako::Runtime
- Defined in:
- lib/kobako/runtime.rb,
sig/kobako/runtime.rbs
Overview
Host-side wasmtime runtime, surfaced as a Ruby class by the native ext
(see ext/kobako/src/runtime.rs). The Kobako::Runtime class wraps the
wasmtime engine + compiled module + Store; it is the only Ruby-visible
wasmtime type and the foundational binding layer for Kobako::Sandbox.
This file reopens the magnus-defined class only to add the pure-Ruby
.default_path helper. Every other method (+#from_path+ singleton,
#eval / #run, capture and usage readers) is registered from Rust
at ext load time.
Defined Under Namespace
Classes: GuestYielder
Class Method Summary collapse
-
.default_path ⇒ String
Absolute path to the gem-bundled
data/kobako.wasmartifact. - .from_path ⇒ Object
Instance Method Summary collapse
- #captures ⇒ [String, bool, String, bool]
- #eval ⇒ String
- #on_dispatch= ⇒ void
- #profile ⇒ Symbol
- #run ⇒ String
- #usage ⇒ [Float, Integer]
Class Method Details
.default_path ⇒ String
Absolute path to the gem-bundled data/kobako.wasm artifact. Computed
from this file's location so it works for both bundle exec (running
from the repo) and an installed gem (running from the gem dir).
Returns a String regardless of whether the file currently exists —
call sites that need the file to be present should pass this through
Kobako::Runtime.from_path, which raises
Kobako::ModuleNotBuiltError with a clear remediation message.
Raises Kobako::SetupError if __dir__ is unavailable so that
rescue Kobako::SetupError around Kobako::Sandbox.new catches every
construction-layer failure uniformly, including this path-resolution one.
25 26 27 28 |
# File 'lib/kobako/runtime.rb', line 25 def self.default_path dir = __dir__ or raise Kobako::SetupError, "Kobako::Runtime.default_path requires __dir__" File.("../../data/kobako.wasm", dir) end |
.from_path ⇒ Object
5 |
# File 'sig/kobako/runtime.rbs', line 5
def self.from_path: (
|
Instance Method Details
#captures ⇒ [String, bool, String, bool]
22 |
# File 'sig/kobako/runtime.rbs', line 22
def captures: () -> [String, bool, String, bool]
|
#eval ⇒ String
16 |
# File 'sig/kobako/runtime.rbs', line 16
def eval: (String preamble, String source, String snippets) -> String
|
#on_dispatch= ⇒ void
This method returns an undefined value.
14 |
# File 'sig/kobako/runtime.rbs', line 14
def on_dispatch=: (^(String, Kobako::Transport::_GuestYielder) -> String dispatch_proc) -> void
|
#profile ⇒ Symbol
24 |
# File 'sig/kobako/runtime.rbs', line 24
def profile: () -> Symbol
|
#run ⇒ String
18 |
# File 'sig/kobako/runtime.rbs', line 18
def run: (String preamble, String snippets, String envelope) -> String
|
#usage ⇒ [Float, Integer]
20 |
# File 'sig/kobako/runtime.rbs', line 20
def usage: () -> [Float, Integer]
|