mirror of
https://github.com/denoland/deno.git
synced 2024-10-30 09:08:00 -04:00
22 lines
463 B
Rust
22 lines
463 B
Rust
use crate::isolate::PinnedBuf;
|
|
use crate::ops::CoreOp;
|
|
|
|
pub type PluginInitFn = fn(context: &mut dyn PluginInitContext);
|
|
|
|
pub trait PluginInitContext {
|
|
fn register_op(
|
|
&mut self,
|
|
name: &str,
|
|
op: Box<dyn Fn(&[u8], Option<PinnedBuf>) -> 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)
|
|
}
|
|
};
|
|
}
|