rhai/src/plugin.rs

39 lines
1.3 KiB
Rust
Raw Normal View History

//! Module defining macros for developing _plugins_.
2020-07-02 06:47:24 +02:00
pub use crate::any::Dynamic;
pub use crate::engine::Engine;
pub use crate::fn_native::CallableFunction;
pub use crate::fn_register::{RegisterFn, RegisterResultFn};
pub use crate::module::Module;
pub use crate::parser::FnAccess;
pub use crate::result::EvalAltResult;
pub use crate::utils::ImmutableString;
pub use crate::stdlib::{any::TypeId, boxed::Box, format, mem, vec as new_vec};
2020-08-03 02:27:19 +02:00
#[cfg(not(features = "no_module"))]
2020-08-03 02:27:19 +02:00
pub use rhai_codegen::*;
2020-09-10 11:42:34 +02:00
#[cfg(features = "no_module")]
pub use rhai_codegen::{export_fn, register_exported_fn};
2020-07-02 06:47:24 +02:00
/// Trait implemented by a _plugin function_.
/// This trait should not be used directly.
2020-07-02 06:47:24 +02:00
///
/// Use the `#[export_module]` and `#[export_fn]` procedural attributes instead.
2020-07-02 06:47:24 +02:00
pub trait PluginFunction {
/// Call the plugin function with the arguments provided.
fn call(&self, args: &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>;
/// Is this plugin function a method?
2020-07-02 06:47:24 +02:00
fn is_method_call(&self) -> bool;
/// Is this plugin function variadic?
fn is_variadic(&self) -> bool;
2020-07-02 06:47:24 +02:00
/// Convert a plugin function into a boxed trait object.
2020-07-02 06:47:24 +02:00
fn clone_boxed(&self) -> Box<dyn PluginFunction>;
2020-08-01 18:52:26 +02:00
/// Return a boxed slice of type ID's of the function's parameters.
2020-08-01 18:52:26 +02:00
fn input_types(&self) -> Box<[TypeId]>;
2020-07-02 06:47:24 +02:00
}