diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2022-09-29 19:34:16 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-29 19:34:16 +0900 |
commit | 15ea624790f2f96ba9d852f34d114d6c8329245a (patch) | |
tree | 48c35cd381ec1db148b1d7341f95054212b8a194 /runtime/permissions.rs | |
parent | 37887d4a1f2a4fc10347993143a50a17495e9f53 (diff) |
refactor(cli): use shared sys kind parser in flags.rs (#16087)
Diffstat (limited to 'runtime/permissions.rs')
-rw-r--r-- | runtime/permissions.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/runtime/permissions.rs b/runtime/permissions.rs index 84ff286b4..1568410b3 100644 --- a/runtime/permissions.rs +++ b/runtime/permissions.rs @@ -3,6 +3,7 @@ use crate::colors; use crate::fs_util::resolve_from_cwd; use deno_core::error::custom_error; +use deno_core::error::type_error; use deno_core::error::uri_error; use deno_core::error::AnyError; #[cfg(test)] @@ -304,6 +305,14 @@ impl ToString for RunDescriptor { #[derive(Clone, Eq, PartialEq, Hash, Debug)] pub struct SysDescriptor(pub String); +pub fn parse_sys_kind(kind: &str) -> Result<&str, AnyError> { + match kind { + "hostname" | "osRelease" | "loadavg" | "networkInterfaces" + | "systemMemoryInfo" | "getUid" | "getGid" => Ok(kind), + _ => Err(type_error(format!("unknown system info kind \"{}\"", kind))), + } +} + #[derive(Clone, Eq, PartialEq, Hash, Debug)] pub struct FfiDescriptor(pub PathBuf); |