rhai/src/func/plugin.rs

33 lines
1004 B
Rust
Raw Normal View History

//! Module defining macros for developing _plugins_.
2020-07-02 06:47:24 +02:00
2021-11-16 05:26:37 +01:00
pub use super::CallableFunction;
use super::FnCallArgs;
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-11-16 05:26:37 +01:00
2022-06-05 12:17:44 +02:00
/// Result of a Rhai function.
2021-12-25 16:49:14 +01:00
pub type RhaiResult = crate::RhaiResult;
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;
}