rhai/src/plugin.rs

31 lines
1010 B
Rust
Raw Normal View History

//! Module defining macros for developing _plugins_.
2020-07-02 06:47:24 +02:00
2021-06-17 03:50:32 +02:00
use crate::fn_call::FnCallArgs;
pub use crate::fn_native::CallableFunction;
2020-11-16 16:10:14 +01:00
pub use crate::{
2020-11-17 05:23:53 +01:00
Dynamic, Engine, EvalAltResult, FnAccess, FnNamespace, ImmutableString, Module,
NativeCallContext, Position,
2020-11-16 16:10:14 +01:00
};
2021-04-17 09:15:54 +02:00
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
pub use std::{any::TypeId, mem};
2021-03-19 03:30:30 +01:00
pub type RhaiResult = Result<Dynamic, Box<EvalAltResult>>;
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_.
2020-07-02 06:47:24 +02:00
///
2020-12-26 06:05:57 +01:00
/// This trait should not be used directly.
/// 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.
2021-03-02 08:02:28 +01:00
fn call(&self, context: NativeCallContext, args: &mut FnCallArgs) -> RhaiResult;
/// Is this plugin function a method?
2021-06-12 16:47:43 +02:00
#[must_use]
2020-07-02 06:47:24 +02:00
fn is_method_call(&self) -> bool;
}