1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-14 16:33:45 -05:00
denoland-deno/core/plugin_api.rs
Aaron O'Mullan fc9c7de94b
cleanup(core): replace OpResponse with OpResult (#10434)
Drop the Value/Buffer enum since #10432 allows buffers to be serialized rust => v8
2021-04-30 10:51:54 -04:00

22 lines
852 B
Rust

// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
// This file defines the public interface for dynamically loaded plugins.
// The plugin needs to do all interaction with the CLI crate through trait
// objects and function pointers. This ensures that no concrete internal methods
// (such as register_op and the closures created by it) can end up in the plugin
// shared library itself, which would cause segfaults when the plugin is
// unloaded and all functions in the plugin library are unmapped from memory.
pub use crate::Op;
pub use crate::OpId;
pub use crate::OpResult;
pub use crate::ZeroCopyBuf;
pub type InitFn = fn(&mut dyn Interface);
pub type DispatchOpFn = fn(&mut dyn Interface, Option<ZeroCopyBuf>) -> Op;
pub trait Interface {
fn register_op(&mut self, name: &str, dispatcher: DispatchOpFn) -> OpId;
}