summaryrefslogtreecommitdiff
path: root/runtime/ops/permissions.rs
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-04-05 18:40:24 +0200
committerGitHub <noreply@github.com>2021-04-05 18:40:24 +0200
commit2aed322dd507a8568b6ee6f4897e9a8e3220f763 (patch)
treee9a45c0b7688a9881ea9ce132b92554ef2955ad6 /runtime/ops/permissions.rs
parent284e6c303956e8ca20af63b4ecc045438a260fe6 (diff)
refactor: convert ops to use serde_v8 (#10009)
This commit rewrites most of the ops to use "serde_v8" instead of "json" serialization.
Diffstat (limited to 'runtime/ops/permissions.rs')
-rw-r--r--runtime/ops/permissions.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/runtime/ops/permissions.rs b/runtime/ops/permissions.rs
index 61eed6bf4..be8c9974c 100644
--- a/runtime/ops/permissions.rs
+++ b/runtime/ops/permissions.rs
@@ -4,8 +4,6 @@ use crate::permissions::Permissions;
use deno_core::error::custom_error;
use deno_core::error::uri_error;
use deno_core::error::AnyError;
-use deno_core::serde_json::json;
-use deno_core::serde_json::Value;
use deno_core::url;
use deno_core::OpState;
use deno_core::ZeroCopyBuf;
@@ -29,7 +27,7 @@ pub fn op_query_permission(
state: &mut OpState,
args: PermissionArgs,
_zero_copy: Option<ZeroCopyBuf>,
-) -> Result<Value, AnyError> {
+) -> Result<String, AnyError> {
let permissions = state.borrow::<Permissions>();
let path = args.path.as_deref();
let perm = match args.name.as_ref() {
@@ -53,14 +51,14 @@ pub fn op_query_permission(
))
}
};
- Ok(json!({ "state": perm.to_string() }))
+ Ok(perm.to_string())
}
pub fn op_revoke_permission(
state: &mut OpState,
args: PermissionArgs,
_zero_copy: Option<ZeroCopyBuf>,
-) -> Result<Value, AnyError> {
+) -> Result<String, AnyError> {
let permissions = state.borrow_mut::<Permissions>();
let path = args.path.as_deref();
let perm = match args.name.as_ref() {
@@ -84,14 +82,14 @@ pub fn op_revoke_permission(
))
}
};
- Ok(json!({ "state": perm.to_string() }))
+ Ok(perm.to_string())
}
pub fn op_request_permission(
state: &mut OpState,
args: PermissionArgs,
_zero_copy: Option<ZeroCopyBuf>,
-) -> Result<Value, AnyError> {
+) -> Result<String, AnyError> {
let permissions = state.borrow_mut::<Permissions>();
let path = args.path.as_deref();
let perm = match args.name.as_ref() {
@@ -115,7 +113,7 @@ pub fn op_request_permission(
))
}
};
- Ok(json!({ "state": perm.to_string() }))
+ Ok(perm.to_string())
}
fn parse_host(host_str: &str) -> Result<(String, Option<u16>), AnyError> {