Skip to content

Commit

Permalink
format test plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
afinch7 committed Jun 25, 2019
1 parent 1c2f6be commit 1003661
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
31 changes: 17 additions & 14 deletions tests/plugin/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
use deno::{PinnedBuf, Buf};
use deno::plugins::{PluginOpResult, new_plugin_error};
use deno::plugins::{new_plugin_error, PluginOpResult};
use deno::Op;
use deno::{Buf, PinnedBuf};

#[macro_use]
extern crate deno;
Expand All @@ -11,17 +11,20 @@ pub fn op_test_op(
data: &[u8],
zero_copy: Option<PinnedBuf>,
) -> PluginOpResult {
if !is_sync {
return Err(new_plugin_error(String::from("Async not supported!")));
}
if let Some(buf) = zero_copy {
let data_str = std::str::from_utf8(&data[..]).unwrap();
let buf_str = std::str::from_utf8(&buf[..]).unwrap();
println!("Hello from native bindings. data: {} | zero_copy: {}", data_str, buf_str);
}
let result = b"test";
let result_box: Buf = Box::new(*result);
Ok(Op::Sync(result_box))
if !is_sync {
return Err(new_plugin_error(String::from("Async not supported!")));
}
if let Some(buf) = zero_copy {
let data_str = std::str::from_utf8(&data[..]).unwrap();
let buf_str = std::str::from_utf8(&buf[..]).unwrap();
println!(
"Hello from native bindings. data: {} | zero_copy: {}",
data_str, buf_str
);
}
let result = b"test";
let result_box: Buf = Box::new(*result);
Ok(Op::Sync(result_box))
}

declare_plugin_op!(test_op, op_test_op);
declare_plugin_op!(test_op, op_test_op);
2 changes: 1 addition & 1 deletion tools/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ def qrun(cmd, env=None):
"third_party/rustfmt/" + platform() + "/rustfmt",
"--config-path",
rustfmt_config,
] + find_exts(["cli", "core", "tools"], [".rs"]))
] + find_exts(["cli", "core", "tools", "tests/plugin"], [".rs"]))

0 comments on commit 1003661

Please sign in to comment.