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

pub enum CallableFunction {
    Pure(Arc<dyn Fn(NativeCallContext<'_>, &mut [&mut Dynamic]) + 'static + Sync + Send>),
    Method(Arc<dyn Fn(NativeCallContext<'_>, &mut [&mut Dynamic]) + 'static + Sync + Send>),
    Iterator(fn(Dynamic) -> Box<dyn Iterator<Item = Dynamic> + 'static, Global>),
    Plugin(Arc<dyn PluginFunction + 'static + Sync + Send>),
}

A type encapsulating a function callable by Rhai.

Variants

Pure(Arc<dyn Fn(NativeCallContext<'_>, &mut [&mut Dynamic]) + 'static + Sync + Send>)

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

Method(Arc<dyn Fn(NativeCallContext<'_>, &mut [&mut Dynamic]) + 'static + Sync + Send>)

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> + 'static, Global>)

An iterator function.

Plugin(Arc<dyn PluginFunction + 'static + Sync + Send>)

A plugin 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
) -> &Arc<dyn Fn(NativeCallContext<'_>, &mut [&mut Dynamic]) + 'static + Sync + Send>
[src]

Get a shared reference to a native Rust function.

Panics

Panics if the CallableFunction is not Pure or Method.

pub fn get_iter_fn(
    &self
) -> fn(Dynamic) -> Box<dyn Iterator<Item = Dynamic> + 'static, Global>
[src]

Get a reference to an iterator function.

Panics

Panics if the CallableFunction is not Iterator.

pub fn get_plugin_fn(
    &'s self
) -> &'s Arc<dyn PluginFunction + 'static + Sync + Send>
[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 [&mut Dynamic]) + 'static + Sync + Send, Global>
) -> CallableFunction
[src]

Create a new CallableFunction::Pure.

pub fn from_method(
    func: Box<dyn Fn(NativeCallContext<'_>, &mut [&mut Dynamic]) + 'static + Sync + Send, Global>
) -> CallableFunction
[src]

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

Trait Implementations

impl Clone for CallableFunction[src]

impl Debug for CallableFunction[src]

impl Display for CallableFunction[src]

impl From<Arc<dyn PluginFunction + 'static + Sync + Send>> for CallableFunction[src]

impl<T> From<T> for CallableFunction where
    T: 'static + PluginFunction + SendSync, 
[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.