From 5dedb49ac4e18874ce2973ac7c0e491d5ec68155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 6 Sep 2024 10:28:53 +0100 Subject: refactor(permissions): remove FromStr implementations, add ::parse methods (#25473) The `.parse()` calls in permission code are only making it more confusing, verbosity is encouraged and welcome in this code even at the cost of not being concise. Left a couple TODOs to not use `AnyError`. --- runtime/ops/permissions.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'runtime/ops') diff --git a/runtime/ops/permissions.rs b/runtime/ops/permissions.rs index 9ac9205e9..e6974efad 100644 --- a/runtime/ops/permissions.rs +++ b/runtime/ops/permissions.rs @@ -1,6 +1,7 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use ::deno_permissions::parse_sys_kind; +use ::deno_permissions::NetDescriptor; use ::deno_permissions::PermissionState; use ::deno_permissions::PermissionsContainer; use deno_core::error::custom_error; @@ -63,7 +64,7 @@ pub fn op_query_permission( "net" => permissions.net.query( match args.host.as_deref() { None => None, - Some(h) => Some(h.parse()?), + Some(h) => Some(NetDescriptor::parse(h)?), } .as_ref(), ), @@ -97,7 +98,7 @@ pub fn op_revoke_permission( "net" => permissions.net.revoke( match args.host.as_deref() { None => None, - Some(h) => Some(h.parse()?), + Some(h) => Some(NetDescriptor::parse(h)?), } .as_ref(), ), @@ -131,7 +132,7 @@ pub fn op_request_permission( "net" => permissions.net.request( match args.host.as_deref() { None => None, - Some(h) => Some(h.parse()?), + Some(h) => Some(NetDescriptor::parse(h)?), } .as_ref(), ), -- cgit v1.2.3