Polywrap Wasm
Project description
This package contains the runtime for executing Wasm wrappers.
Quickstart
The following code snippet demonstrates how to use the runtime to execute a Wasm wrapper.
Imports
>>> import os >>> from typing import cast >>> from polywrap_core import Uri, FileReader, InvokerClient >>> from polywrap_wasm import WasmWrapper >>> from polywrap_msgpack import msgpack_decode >>> from polywrap_manifest import deserialize_wrap_manifest, AnyWrapManifest
Create a Wasm wrapper
>>> path_to_wrapper = os.path.join(os.path.dirname(__file__), "..", "tests", "cases", "simple") >>> assert os.path.exists(path_to_wrapper) >>> with open(os.path.join(path_to_wrapper, "wrap.wasm"), "rb") as f: ... wasm_module = f.read() >>> assert isinstance(wasm_module, bytes) >>> with open(os.path.join(path_to_wrapper, "wrap.info"), "rb") as f: ... manifest = deserialize_wrap_manifest(f.read()) >>> assert isinstance(manifest, AnyWrapManifest) >>> wrapper = WasmWrapper( ... cast(FileReader, NotImplemented), ... wasm_module, ... manifest ... ) >>> assert isinstance(wrapper, WasmWrapper)
Invocation
>>> message = "Hello, World!" >>> args = {"arg": message} >>> result = wrapper.invoke( ... uri=Uri.from_str("wrap://authority/path"), ... method="simpleMethod", ... args=args, ... client=cast(InvokerClient, NotImplemented), ... ) >>> assert result.encoded is True >>> assert msgpack_decode(cast(bytes, result.result)) == message
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
polywrap_wasm-0.1.2.tar.gz
(13.4 kB
view details)
Built Distribution
File details
Details for the file polywrap_wasm-0.1.2.tar.gz
.
File metadata
- Download URL: polywrap_wasm-0.1.2.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3441fefcfebf242bf0604f08b27a99974b5b9367259eaca9ab42bcaa628a739b |
|
MD5 | 87064bba2fbd758fb2f8ca1475cccd69 |
|
BLAKE2b-256 | 4a63ce7c4f3ed250716d0f0e8289723aea6c8158220c9da3fe6873c12146059e |
File details
Details for the file polywrap_wasm-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: polywrap_wasm-0.1.2-py3-none-any.whl
- Upload date:
- Size: 24.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbcaec24ab7349a15a6c3b71ca5978d11888b50d2eb195058f3111e68e91c01a |
|
MD5 | 23099200a210cef2b363567bae77d0cc |
|
BLAKE2b-256 | f16cf92a09db73defd5e1f571707f9f127d6e922e0b0d4dad6325ddd236813d7 |