import sys from phasmplatform.common import valuetype from phasmplatform.common.config import from_toml from phasmplatform.common.method import Method, MethodArgument from phasmplatform.common.router import StdOutRouter from phasmplatform.common.value import Value from .runners.base import RunnerInterface from .runners.wasmtime import WasmTimeRunner def somefunc(runner: RunnerInterface) -> None: inp = Value(valuetype.bytes, b'Hello, world!') print('inp', inp) def on_respond(out: Value) -> None: print('out', out) assert out == inp echo = Method('echo', [MethodArgument('msg', valuetype.bytes)], valuetype.bytes) runner.do_call(echo, [inp], on_respond) def main() -> int: with open('config.toml', 'rb') as fil: config = from_toml(fil) del config stdout_router = StdOutRouter() with open('/home/johan/projects/idea/phasm/examples/platform.wasm', 'rb') as fil: foo = WasmTimeRunner(stdout_router, fil.read()) # namespace = b'test-namespace' # topic = b'test-topic' # kind = b'test-kind' # body = b'test-body' # foo.handle_message(namespace, topic, kind, body) somefunc(foo) return 0 if __name__ == '__main__': sys.exit(main())