Skip to content

Commit fcaebf0

Browse files
fix: address code review comments
1 parent 7c99f0e commit fcaebf0

File tree

3 files changed

+8
-26
lines changed

3 files changed

+8
-26
lines changed

crates/spidermonkey-embedding-splicer/src/bin/splicer.rs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
use anyhow::{Context, Result};
2-
use clap::{Parser, Subcommand};
31
use std::fs;
42
use std::path::PathBuf;
3+
use std::str::FromStr;
4+
5+
use anyhow::{Context, Result};
6+
use clap::{Parser, Subcommand};
57

68
use spidermonkey_embedding_splicer::wit::exports::local::spidermonkey_embedding_splicer::splicer::Features;
79
use spidermonkey_embedding_splicer::{splice, stub_wasi};
@@ -62,27 +64,6 @@ enum Commands {
6264
},
6365
}
6466

65-
/// Maps the list of features passed as strings into the list of features as given by the enum
66-
///
67-
/// enum features {
68-
/// stdio,
69-
/// clocks,
70-
/// random,
71-
/// http,
72-
///}
73-
fn map_features(features: &[String]) -> Vec<Features> {
74-
features
75-
.iter()
76-
.map(|f| match f.as_str() {
77-
"stdio" => Features::Stdio,
78-
"clocks" => Features::Clocks,
79-
"random" => Features::Random,
80-
"http" => Features::Http,
81-
_ => panic!("Unknown feature: {f}"),
82-
})
83-
.collect()
84-
}
85-
8667
fn main() -> Result<()> {
8768
let cli = Cli::parse();
8869

@@ -98,7 +79,10 @@ fn main() -> Result<()> {
9879
.with_context(|| format!("Failed to read input file: {}", input.display()))?;
9980

10081
let wit_path_str = wit_path.as_ref().map(|p| p.to_string_lossy().to_string());
101-
let features = map_features(&features);
82+
let features = features
83+
.iter()
84+
.map(|v| Features::from_str(v))
85+
.collect::<Result<Vec<_>>>()?;
10286

10387
let result = stub_wasi::stub_wasi(wasm, features, None, wit_path_str, world_name)
10488
.map_err(|e| anyhow::anyhow!(e))?;

crates/spidermonkey-embedding-splicer/src/wit.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ impl std::str::FromStr for Features {
1616
"clocks" => Ok(Features::Clocks),
1717
"random" => Ok(Features::Random),
1818
"http" => Ok(Features::Http),
19-
"fetch-event" => Ok(Features::FetchEvent),
2019
_ => bail!("unrecognized feature string [{s}]"),
2120
}
2221
}

crates/spidermonkey-embedding-splicer/wit/spidermonkey-embedding-splicer.wit

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ interface splicer {
1313
clocks,
1414
random,
1515
http,
16-
fetch-event,
1716
}
1817

1918
record core-fn {

0 commit comments

Comments
 (0)