1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-14 16:33:45 -05:00
denoland-deno/core/plugins.rs

25 lines
480 B
Rust
Raw Normal View History

2020-01-24 15:10:49 -05:00
use crate::isolate::ZeroCopyBuf;
use crate::ops::CoreOp;
pub type PluginInitFn = fn(context: &mut dyn PluginInitContext);
pub trait PluginInitContext {
fn register_op(
&mut self,
name: &str,
2020-01-24 15:10:49 -05:00
op: Box<
dyn Fn(&[u8], Option<ZeroCopyBuf>) -> CoreOp + Send + Sync + 'static,
>,
);
}
#[macro_export]
macro_rules! init_fn {
($fn:path) => {
#[no_mangle]
pub fn deno_plugin_init(context: &mut dyn PluginInitContext) {
$fn(context)
}
};
}