Class: Kobako::Runtime

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Class Method Details

.default_pathString

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.

Returns:

  • (String)


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.expand_path("../../data/kobako.wasm", dir)
end

.from_pathObject



5
# File 'sig/kobako/runtime.rbs', line 5

def self.from_path: (

Instance Method Details

#captures[String, bool, String, bool]

Returns:

  • ([String, bool, String, bool])


22
# File 'sig/kobako/runtime.rbs', line 22

def captures: () -> [String, bool, String, bool]

#evalString

Parameters:

  • preamble (String)
  • source (String)
  • snippets (String)

Returns:

  • (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

#profileSymbol

Returns:

  • (Symbol)


24
# File 'sig/kobako/runtime.rbs', line 24

def profile: () -> Symbol

#runString

Parameters:

  • preamble (String)
  • snippets (String)
  • envelope (String)

Returns:

  • (String)


18
# File 'sig/kobako/runtime.rbs', line 18

def run: (String preamble, String snippets, String envelope) -> String

#usage[Float, Integer]

Returns:

  • ([Float, Integer])


20
# File 'sig/kobako/runtime.rbs', line 20

def usage: () -> [Float, Integer]