diff --git a/Cargo.lock b/Cargo.lock index ae57084..83bd3e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -510,48 +510,6 @@ dependencies = [ "uuid", ] -[[package]] -name = "phf" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" -dependencies = [ - "phf_macros", - "phf_shared", -] - -[[package]] -name = "phf_generator" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" -dependencies = [ - "phf_shared", - "rand", -] - -[[package]] -name = "phf_macros" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" -dependencies = [ - "phf_generator", - "phf_shared", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "phf_shared" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" -dependencies = [ - "siphasher", -] - [[package]] name = "pin-project-lite" version = "0.2.16" @@ -583,7 +541,6 @@ dependencies = [ "log", "miette", "partitioning", - "phf", "test-log", "types", ] @@ -603,21 +560,6 @@ version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" - [[package]] name = "regex" version = "1.11.1" @@ -740,12 +682,6 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c11532d9d241904f095185f35dcdaf930b1427a94d5b01d7002d74ba19b44cc4" -[[package]] -name = "siphasher" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" - [[package]] name = "snafu" version = "0.8.5" diff --git a/Cargo.toml b/Cargo.toml index 70b8ee8..75bbf96 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,6 @@ kdl = "6.3.3" log = "0.4.21" miette = "7.5.0" nix = { version = "0.30.1", features = ["fs", "mount"] } -phf = "0.11" serde = { version = "1.0" } serde_json = "1.0" snafu = "0.8.5" diff --git a/crates/provisioning/Cargo.toml b/crates/provisioning/Cargo.toml index 00aa94c..f090d38 100644 --- a/crates/provisioning/Cargo.toml +++ b/crates/provisioning/Cargo.toml @@ -14,6 +14,5 @@ types = { path = "../types", features = ["kdl"] } kdl = { workspace = true, features = ["span"] } miette = { workspace = true } itertools = { workspace = true } -phf = { workspace = true, features = ["macros"] } test-log.workspace = true log.workspace = true diff --git a/crates/provisioning/src/commands.rs b/crates/provisioning/src/commands.rs index 1af5b0d..d5bfcce 100644 --- a/crates/provisioning/src/commands.rs +++ b/crates/provisioning/src/commands.rs @@ -20,17 +20,19 @@ pub enum Command { /// Command execution function type CommandExec = for<'a> fn(Context<'a>) -> Result; -/// Map of command names to functions -static COMMANDS: phf::Map<&'static str, CommandExec> = phf::phf_map! { - "find-disk" => find_disk::parse, - "create-partition" => create_partition::parse, - "create-partition-table" => create_partition_table::parse, -}; +fn command(name: &str) -> Option { + Some(match name { + "find-disk" => find_disk::parse, + "create-partition" => create_partition::parse, + "create-partition-table" => create_partition_table::parse, + _ => return None, + }) +} /// Parse a command from a node if possible pub(crate) fn parse_command(context: Context<'_>) -> Result { let name = context.node.name().value(); - let func = COMMANDS.get(name).ok_or_else(|| crate::UnsupportedNode { + let func = command(name).ok_or_else(|| crate::UnsupportedNode { at: context.node.span(), name: name.into(), })?;