Skip to content

Commit

Permalink
Update inspector example to no longer hardcode file
Browse files Browse the repository at this point in the history
  • Loading branch information
AldaronLau committed Jun 13, 2023
1 parent 7797e3a commit 9f87e82
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions examples/inspector.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
use std::{env, fs};

use nucleide::{
daku::Nucleide, name::Name, producers::ProducerKind, Module, Section,
};

fn main() {
const BYTES: &[u8] = include_bytes!(
"../hello_world/target/wasm32-unknown-unknown/debug/hello_world.wasm",
);
let path = env::args()
.skip(1)
.next()
.expect("Need to provide wasm file");
let bytes = fs::read(path).expect("Could not open file");

for section in Module::new(BYTES)
for section in Module::new(bytes.as_slice())
.expect("Bad WASM file")
.sections()
.expect("Incorrect section order")
Expand All @@ -31,7 +35,7 @@ fn main() {
match section {
Section::Name(names) => {
println!("§ `name`");
println!("========");
println!("————————");
for name in names {
match name {
Name::Module(name) => {
Expand Down Expand Up @@ -97,7 +101,7 @@ fn main() {
}
Section::Producers(producers) => {
println!("§ `producers`");
println!("=============");
println!("—————————————");

for producer_group in producers {
let kind = match producer_group.kind {
Expand All @@ -120,7 +124,7 @@ fn main() {
}
Section::Daku(daku) => {
println!("§ `daku`");
println!("========");
println!("————————");
println!(" • Portals:");

for portal in daku.portals {
Expand Down

0 comments on commit 9f87e82

Please sign in to comment.