Enum casbin::rhai::plugin::RhaiFunc

source ·
#[non_exhaustive]
pub enum RhaiFunc { Pure { func: Arc<dyn Fn(Option<NativeCallContext<'_>>, &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> + Send + Sync>, has_context: bool, is_pure: bool, is_volatile: bool, }, Method { func: Arc<dyn Fn(Option<NativeCallContext<'_>>, &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> + Send + Sync>, has_context: bool, is_pure: bool, is_volatile: bool, }, Iterator { func: Arc<dyn Fn(Dynamic) -> Box<dyn Iterator<Item = Result<Dynamic, Box<EvalAltResult>>>> + Send + Sync>, }, Plugin { func: Arc<dyn PluginFunc + Send + Sync>, }, }
Expand description

(internals) A type encapsulating a function callable by Rhai. Exported under the internals feature only.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Pure

Fields

§func: Arc<dyn Fn(Option<NativeCallContext<'_>>, &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> + Send + Sync>

Shared function pointer.

§has_context: bool

Does the function take a NativeCallContext parameter?

§is_pure: bool

This is a dummy field and is not used.

§is_volatile: bool

Is this function volatile?

A volatile function does not guarantee the same result for the same input(s).

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

§

Method

Fields

§func: Arc<dyn Fn(Option<NativeCallContext<'_>>, &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> + Send + Sync>

Shared function pointer.

§has_context: bool

Does the function take a NativeCallContext parameter?

§is_pure: bool

Allow operating on constants?

§is_volatile: bool

Is this function volatile?

A volatile function does not guarantee the same result for the same input(s).

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

§

Iterator

Fields

§func: Arc<dyn Fn(Dynamic) -> Box<dyn Iterator<Item = Result<Dynamic, Box<EvalAltResult>>>> + Send + Sync>

Shared function pointer.

An iterator function.

§

Plugin

Fields

§func: Arc<dyn PluginFunc + Send + Sync>

Shared function pointer.

A plugin function,

Implementations§

source§

impl RhaiFunc

source

pub fn is_pure(&self) -> bool

Is this a pure native Rust function?

source

pub fn is_method(&self) -> bool

Is this a native Rust method function?

source

pub const fn is_iter(&self) -> bool

Is this an iterator function?

source

pub const fn is_script(&self) -> bool

Is this a script-defined function?

source

pub const fn is_plugin_fn(&self) -> bool

Is this a plugin function?

source

pub const fn is_native(&self) -> bool

Is this a native Rust function?

source

pub fn has_context(&self) -> bool

Is there a NativeCallContext parameter?

source

pub fn is_volatile(&self) -> bool

Is this function volatile?

A volatile function does not guarantee the same result for the same input(s).

source

pub fn access(&self) -> FnAccess

Get the access mode.

source

pub fn get_native_fn( &self ) -> Option<&Arc<dyn Fn(Option<NativeCallContext<'_>>, &mut [&mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>> + Send + Sync>>

Get a shared reference to a native Rust function.

source

pub fn get_encapsulated_environ(&self) -> Option<&EncapsulatedEnviron>

Get a reference to the shared encapsulated environment of the function definition.

Not available under no_function or no_module.

source

pub fn get_iter_fn( &self ) -> Option<&(dyn Fn(Dynamic) -> Box<dyn Iterator<Item = Result<Dynamic, Box<EvalAltResult>>>> + Send + Sync + 'static)>

Get a reference to an iterator function.

source

pub fn get_plugin_fn(&self) -> Option<&Arc<dyn PluginFunc + Send + Sync>>

Get a shared reference to a plugin function.

Trait Implementations§

source§

impl Clone for RhaiFunc

source§

fn clone(&self) -> RhaiFunc

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RhaiFunc

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Display for RhaiFunc

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl From<Arc<dyn PluginFunc + Send + Sync>> for RhaiFunc

source§

fn from(func: Arc<dyn PluginFunc + Send + Sync>) -> RhaiFunc

Converts to this type from the input type.
source§

impl<T> From<T> for RhaiFunc
where T: PluginFunc + 'static + SendSync,

source§

fn from(func: T) -> RhaiFunc

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.