Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
afinch7 committed Aug 27, 2020
1 parent 753dcb1 commit e694c07
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
5 changes: 2 additions & 3 deletions core/plugin_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ pub use crate::ZeroCopyBuf;

pub type InitFn = fn(&mut dyn Interface);

pub type DispatchOpFn =
dyn Fn(&mut dyn Interface, &mut [ZeroCopyBuf]) -> Op;
pub type DispatchOpFn = dyn Fn(&mut dyn Interface, &mut [ZeroCopyBuf]) -> Op;
pub trait Interface {
fn register_op(&mut self, name: &str, dispatcher: Box<DispatchOpFn>) -> OpId;
}
}
24 changes: 11 additions & 13 deletions test_plugin/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use deno_core::plugin_api::Buf;
use deno_core::plugin_api::DispatchOpFn;
use deno_core::plugin_api::Interface;
use deno_core::plugin_api::Op;
use deno_core::plugin_api::ZeroCopyBuf;
use deno_core::plugin_api::DispatchOpFn;
use futures::future::FutureExt;

#[no_mangle]
#[no_mangle]
pub fn deno_plugin_init(interface: &mut dyn Interface) {
interface.register_op("testSync", Box::new(op_test_sync));
interface.register_op("testAsync", Box::new(op_test_async));
Expand Down Expand Up @@ -56,18 +56,16 @@ fn op_test_async(
Op::Async(fut.boxed())
}

fn wrap_op<D>(d: D) -> Box<DispatchOpFn>
where
D: Fn(
&mut dyn Interface,
String,
&mut [ZeroCopyBuf],
) -> Op + 'static
fn wrap_op<D>(d: D) -> Box<DispatchOpFn>
where
D: Fn(&mut dyn Interface, String, &mut [ZeroCopyBuf]) -> Op + 'static,
{
Box::new(move |i: &mut dyn Interface, zero_copy: &mut [ZeroCopyBuf]| {
let first_buf_str = std::str::from_utf8(&zero_copy[0][..]).unwrap();
d(i, first_buf_str.to_string(), &mut zero_copy[1..])
})
Box::new(
move |i: &mut dyn Interface, zero_copy: &mut [ZeroCopyBuf]| {
let first_buf_str = std::str::from_utf8(&zero_copy[0][..]).unwrap();
d(i, first_buf_str.to_string(), &mut zero_copy[1..])
},
)
}

fn op_wrapped(
Expand Down
4 changes: 3 additions & 1 deletion test_plugin/tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ const promiseTestAsync = new Promise((resolve) => resolveTestAsync = resolve);

let resolveTestWrapped;

const promiseTestWrapped = new Promise((resolve) => resolveTestWrapped = resolve);
const promiseTestWrapped = new Promise((resolve) =>
resolveTestWrapped = resolve
);

function runTestSync() {
const response = Deno.core.dispatch(
Expand Down

0 comments on commit e694c07

Please sign in to comment.