polywrap_wasm.wasm_package module
This module contains the WasmPackage type for loading a Wasm package.
- class polywrap_wasm.wasm_package.WasmPackage(file_reader: FileReader, manifest: bytes | WrapManifest | None = None, wasm_module: bytes | None = None)[source]
Bases:
WrapPackageWasmPackage implements the WRAP package protocol for a Wasm WRAP package.
- Parameters:
file_reader (FileReader) – The file reader used to read the package files.
manifest (Optional[Union[bytes, AnyWrapManifest]]) – The manifest of the wrapper.
wasm_module (Optional[bytes]) – The Wasm module file of the wrapper.
- create_wrapper() Wrapper[source]
Create a new WasmWrapper instance.
- Returns:
The Wasm wrapper instance.
- Return type:
- Raises:
OSError – If the wasm module or manifest could not be read due to system errors.
MsgpackDecodeError – If the encoded manifest fails to decode.
ManifestError – If the manifest is not valid.
- file_reader: FileReader
- get_manifest(options: DeserializeManifestOptions | None = None) WrapManifest[source]
Get the manifest of the wrapper.
- Parameters:
options (Optional[DeserializeManifestOptions]) – The options to use when getting the manifest.
- Returns:
The manifest of the wrapper.
- Return type:
AnyWrapManifest
- Raises:
OSError – If the manifest file could not be read due to system errors.
MsgpackDecodeError – If the encoded manifest fails to decode.
ManifestError – If the manifest is not valid.
- get_wasm_module() bytes[source]
Get the Wasm module of the wrapper if it exists or return an error.
- Raises:
OSError – If the wasm module file could not be read due to system errors.
- Returns:
The Wasm module of the wrapper or an error.
- manifest: bytes | WrapManifest | None
- wasm_module: bytes | None