File: roundtrip.rs

package info (click to toggle)
rust-parity-wasm 0.35.5-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 480 kB
  • sloc: makefile: 2
file content (27 lines) | stat: -rw-r--r-- 601 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
extern crate parity_wasm;

use std::env;

fn main() {
	let args = env::args().collect::<Vec<_>>();
	if args.len() != 3 {
		println!("Usage: {} in.wasm out.wasm", args[0]);
		return;
	}

	let module = match parity_wasm::deserialize_file(&args[1])
		.expect("Failed to load module")
		.parse_names()
		.and_then(|module| module.parse_reloc())
	{
		Ok(m) => m,
		Err((errors, m)) => {
			for (index, error) in errors.into_iter() {
				println!("Custom section #{} parse error: {:?}", index, error);
			}
			m
		}
	};

	parity_wasm::serialize_to_file(&args[2], module).expect("Failed to write module");
}