Enum rhai::plugin::CallableFunction[][src]

pub enum CallableFunction {
    Pure(Shared<dyn Fn(NativeCallContext<'_>, &mut FnCallArgs<'_>) -> Result<Dynamic, Box<EvalAltResult>>>),
    Method(Shared<dyn Fn(NativeCallContext<'_>, &mut FnCallArgs<'_>) -> Result<Dynamic, Box<EvalAltResult>>>),
    Iterator(fn(_: Dynamic) -> Box<dyn Iterator<Item = Dynamic>>),
    Plugin(Shared<dyn PluginFunction>),
    Script(Shared<ScriptFnDef>),
}

A type encapsulating a function callable by Rhai.

Variants

A pure native Rust function with all arguments passed by value.

A native Rust object method with the first argument passed by reference, and the rest passed by value.

Iterator(fn(_: Dynamic) -> Box<dyn Iterator<Item = Dynamic>>)

An iterator function.

Plugin(Shared<dyn PluginFunction>)

A plugin function,

A script-defined function.

Implementations

impl CallableFunction[src]

pub fn is_pure(&self) -> bool[src]

Is this a pure native Rust function?

pub fn is_method(&self) -> bool[src]

Is this a native Rust method function?

pub fn is_iter(&self) -> bool[src]

Is this an iterator function?

pub fn is_script(&self) -> bool[src]

Is this a Rhai-scripted function?

pub fn is_plugin_fn(&self) -> bool[src]

Is this a plugin function?

pub fn is_native(&self) -> bool[src]

Is this a native Rust function?

pub fn access(&self) -> FnAccess[src]

Get the access mode.

pub fn get_native_fn(
    &self
) -> &Shared<dyn Fn(NativeCallContext<'_>, &mut FnCallArgs<'_>) -> Result<Dynamic, Box<EvalAltResult>>>
[src]

Get a shared reference to a native Rust function.

Panics

Panics if the CallableFunction is not Pure or Method.

pub fn get_fn_def(&self) -> &Shared<ScriptFnDef>[src]

Get a shared reference to a script-defined function definition.

Panics

Panics if the CallableFunction is not Script.

pub fn get_iter_fn(&self) -> fn(_: Dynamic) -> Box<dyn Iterator<Item = Dynamic>>[src]

Get a reference to an iterator function.

Panics

Panics if the CallableFunction is not Iterator.

pub fn get_plugin_fn<'s>(&'s self) -> &Shared<dyn PluginFunction>[src]

Get a shared reference to a plugin function.

Panics

Panics if the CallableFunction is not Plugin.

pub fn from_pure(
    func: Box<dyn Fn(NativeCallContext<'_>, &mut FnCallArgs<'_>) -> Result<Dynamic, Box<EvalAltResult>>>
) -> Self
[src]

Create a new CallableFunction::Pure.

pub fn from_method(
    func: Box<dyn Fn(NativeCallContext<'_>, &mut FnCallArgs<'_>) -> Result<Dynamic, Box<EvalAltResult>>>
) -> Self
[src]

pub fn from_plugin(func: impl PluginFunction + 'static + SendSync) -> Self[src]

Trait Implementations

impl Clone for CallableFunction[src]

impl Debug for CallableFunction[src]

impl Display for CallableFunction[src]

impl From<Rc<ScriptFnDef>> for CallableFunction[src]

impl From<Rc<dyn PluginFunction + 'static>> for CallableFunction[src]

impl From<ScriptFnDef> for CallableFunction[src]

impl<T: PluginFunction + 'static + SendSync> From<T> for CallableFunction[src]

impl From<fn(Dynamic) -> Box<dyn Iterator<Item = Dynamic> + 'static, Global>> for CallableFunction[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.