Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

polywrap-wasm

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polywrap-wasm

Polywrap Wasm

  • 0.1.2
  • PyPI
  • Socket score

Maintainers
2

Polywrap Wasm

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

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc