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 mut add = AddMetadata ::default();
add.name = Some("program".to_owned());
add.language = vec![("tunalang".to_owned(), "1.0.0".to_owned())];
add.processed_by = vec![("chashu-tools".to_owned(), "1.0.1".to_owned())];
add.sdk = vec![];
add.authors = Some(Authors::new("Chashu Cat"));
add.description = Some(Description::new("Chashu likes tuna"));
add.licenses = Some(Licenses::new("Apache-2.0 WITH LLVM-exception")?);
add.source = Some(Source::new("https://github.com/chashu/chashu-tools")?);
add.homepage = Some(Homepage::new("https://github.com/chashu/chashu-tools")?);
add.revision = Some(Revision::new("de978e17a80c1118f606fce919ba9b7d5a04a5ad"));
add.version = Some(Version::new("1.0.0"));
let wasm = add.to_wasm(&wasm)?;
fs::write("program.wasm", &wasm)?;Structs§
- AddMetadata
- Add metadata (module name, producers) to a WebAssembly file.
- Component
Names - Helper for rewriting a component’s component-name section with a new component name.
- 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