Expand description
Read and manipulate WebAssembly metadata
§Examples
Read metadata from a Wasm binary
use wasm_metadata::Payload;
use std::fs;
let wasm = fs::read("program.wasm")?;
let metadata = Payload::from_binary(&wasm)?.metadata();
Add metadata to a Wasm binary
use wasm_metadata::*;
use std::fs;
let wasm = fs::read("program.wasm")?;
let metadata = AddMetadata {
name: Some("program".to_owned()),
language: vec![("tunalang".to_owned(), "1.0.0".to_owned())],
processed_by: vec![("chashu-tools".to_owned(), "1.0.1".to_owned())],
sdk: vec![],
authors: Some(Authors::new("Chashu Cat")),
description: Some(Description::new("Chashu likes tuna")),
licenses: Some(Licenses::new("Apache-2.0 WITH LLVM-exception")?),
source: Some(Source::new("https://github.com/chashu/chashu-tools")?),
homepage: Some(Homepage::new("https://github.com/chashu/chashu-tools")?),
revision: Some(Revision::new("de978e17a80c1118f606fce919ba9b7d5a04a5ad")),
version: Some(Version::new("1.0.0")),
};
let wasm = metadata.to_wasm(&wasm)?;
fs::write("program.wasm", &wasm)?;
Structs§
- AddMetadata
- Add metadata (module name, producers) to a WebAssembly file.
- Authors
- Contact details of the people or organization responsible, encoded as a freeform string.
- Component
Names - Helper for rewriting a component’s component-name section with a new component name.
- Description
- Human-readable description of the binary
- Homepage
- URL to find more information on the binary
- Licenses
- License(s) under which contained software is distributed as an SPDX License Expression.
- Metadata
- Metadata associated with a Wasm Component or Module
- Module
Names - Helper for rewriting a module’s name section with a new module name.
- Producers
- A representation of a WebAssembly producers section.
- Producers
Field - Contents of a producers field
- Revision
- Source control revision identifier for the packaged software.
- Source
- URL to get source code for building the image
- Version
- Version of the packaged software
Enums§
- Payload
- Data representing either a Wasm Component or module