summaryrefslogtreecommitdiff
path: root/cli/ops/idna.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-08-28 17:08:24 +0200
committerGitHub <noreply@github.com>2020-08-28 17:08:24 +0200
commit7e946858a4a0a03c1461590c6fc8a315738a627a (patch)
tree5a6a391fead573b85fb905bb5c4ea8287dc18d13 /cli/ops/idna.rs
parent31f32ed8c4082d36ad2a4ea460366c0d57a5ddbc (diff)
refactor: migrate ops to new dispatch wrapper (#7118)
Diffstat (limited to 'cli/ops/idna.rs')
-rw-r--r--cli/ops/idna.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/cli/ops/idna.rs b/cli/ops/idna.rs
index 9585e0977..392eceb24 100644
--- a/cli/ops/idna.rs
+++ b/cli/ops/idna.rs
@@ -2,16 +2,21 @@
//! https://url.spec.whatwg.org/#idna
-use super::dispatch_json::{Deserialize, JsonOp, Value};
+use super::dispatch_json::{Deserialize, Value};
use crate::state::State;
use deno_core::CoreIsolate;
use deno_core::ErrBox;
+use deno_core::ResourceTable;
use deno_core::ZeroCopyBuf;
use idna::{domain_to_ascii, domain_to_ascii_strict};
use std::rc::Rc;
pub fn init(i: &mut CoreIsolate, s: &Rc<State>) {
- i.register_op("op_domain_to_ascii", s.stateful_json_op(op_domain_to_ascii));
+ let t = &CoreIsolate::state(i).borrow().resource_table.clone();
+ i.register_op(
+ "op_domain_to_ascii",
+ s.stateful_json_op_sync(t, op_domain_to_ascii),
+ );
}
#[derive(Deserialize)]
@@ -22,10 +27,11 @@ struct DomainToAscii {
}
fn op_domain_to_ascii(
- _state: &Rc<State>,
+ _state: &State,
+ _resource_table: &mut ResourceTable,
args: Value,
_zero_copy: &mut [ZeroCopyBuf],
-) -> Result<JsonOp, ErrBox> {
+) -> Result<Value, ErrBox> {
let args: DomainToAscii = serde_json::from_value(args)?;
if args.be_strict {
domain_to_ascii_strict(args.domain.as_str())
@@ -36,5 +42,5 @@ fn op_domain_to_ascii(
let message = format!("Invalid IDNA encoded domain name: {:?}", err);
ErrBox::new("URIError", message)
})
- .map(|domain| JsonOp::Sync(json!(domain)))
+ .map(|domain| json!(domain))
}