rhai

Enum RhaiFunc

Source
#[non_exhaustive]
pub enum RhaiFunc { Pure { func: Shared<dyn Fn(Option<NativeCallContext<'_>>, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>, has_context: bool, is_pure: bool, is_volatile: bool, }, Method { func: Shared<dyn Fn(Option<NativeCallContext<'_>>, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>, has_context: bool, is_pure: bool, is_volatile: bool, }, Iterator { func: Shared<dyn Fn(Dynamic) -> Box<dyn Iterator<Item = Result<Dynamic, Box<EvalAltResult>>>>>, }, Plugin { func: Shared<dyn PluginFunc>, }, Script { fn_def: Shared<ScriptFuncDef>, environ: Option<Shared<EncapsulatedEnviron>>, }, }
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

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

Fields

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

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).

§

Method

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

Fields

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

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).

§

Iterator

An iterator function.

Fields

§func: Shared<dyn Fn(Dynamic) -> Box<dyn Iterator<Item = Result<Dynamic, Box<EvalAltResult>>>>>

Shared function pointer.

§

Plugin

A plugin function,

Fields

§func: Shared<dyn PluginFunc>

Shared function pointer.

§

Script

A script-defined function.

Fields

§fn_def: Shared<ScriptFuncDef>

Shared reference to the ScriptFuncDef function definition.

§environ: Option<Shared<EncapsulatedEnviron>>

Encapsulated environment, if any.

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<&Shared<dyn Fn(Option<NativeCallContext<'_>>, &mut [&'_ mut Dynamic]) -> Result<Dynamic, Box<EvalAltResult>>>>

Get a shared reference to a native Rust function.

Source

pub const fn get_script_fn_def(&self) -> Option<&Shared<ScriptFuncDef>>

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

Not available under no_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>>>>>

Get a reference to an iterator function.

Source

pub fn get_plugin_fn(&self) -> Option<&Shared<dyn PluginFunc>>

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

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

impl Display for RhaiFunc

Source§

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

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

impl From<Rc<ScriptFuncDef>> for RhaiFunc

Source§

fn from(fn_def: Shared<ScriptFuncDef>) -> Self

Converts to this type from the input type.
Source§

impl From<Rc<dyn PluginFunc>> for RhaiFunc

Source§

fn from(func: Shared<dyn PluginFunc>) -> Self

Converts to this type from the input type.
Source§

impl From<ScriptFuncDef> for RhaiFunc

Source§

fn from(fn_def: ScriptFuncDef) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(func: T) -> Self

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

Source§

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>,

Source§

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>,

Source§

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.
Source§

impl<T> Variant for T
where T: Any + Clone + SendSync,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert this Variant trait object to &dyn Any.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert this Variant trait object to &mut dyn Any.
Source§

fn as_boxed_any(self: Box<T>) -> Box<dyn Any>

Convert this Variant trait object to Box<dyn Any>.
Source§

fn type_name(&self) -> &'static str

Get the name of this type.
Source§

fn clone_object(&self) -> Box<dyn Variant>

Clone this Variant trait object.