Struct rhai::Definitions

source ·
pub struct Definitions<'e> { /* private fields */ }
Expand description

(metadata, internals) Definitions helper type to generate definition files based on the contents of an Engine. Exported under the internals and metadata feature only.

Implementations§

source§

impl Definitions<'_>

source

pub const fn with_headers(self, headers: bool) -> Self

Write module ... headers in separate definitions, default false.

Headers are always present in content that is expected to be written to a file (i.e. write_to* and *_file methods).

source

pub const fn include_standard_packages( self, include_standard_packages: bool ) -> Self

Include standard packages when writing definition files.

source

pub const fn engine(&self) -> &Engine

Get the Engine.

source

pub const fn scope(&self) -> Option<&Scope<'_>>

Get the Scope.

source§

impl Definitions<'_>

source

pub fn write_to_dir(&self, path: impl AsRef<Path>) -> Result<()>

Output all definition files returned from iter_files to a specified directory.

This function creates the directories and overrides any existing files if needed.

source

pub fn write_to_file(&self, path: impl AsRef<Path>) -> Result<()>

Output all definitions merged into a single file.

The parent directory must exist but the file will be created or overwritten as needed.

source

pub fn single_file(&self) -> String

Return all definitions merged into a single file.

source

pub fn iter_files(&self) -> impl Iterator<Item = (String, String)> + '_

Iterate over generated definition files.

The returned iterator yields all definition files as (filename, content) pairs.

source

pub fn builtin_functions(&self) -> String

Return definitions for all builtin functions.

source

pub fn builtin_functions_operators(&self) -> String

Return definitions for all builtin operators.

source

pub fn static_module(&self) -> String

Return definitions for all globally available functions and constants.

source

pub fn scope_items(&self) -> String

Return definitions for all items inside the Scope, if any.

source

pub fn modules(&self) -> impl Iterator<Item = (String, String)> + '_

Return a (module name, definitions) pair for each registered static module.

Not available under no_module.

source§

impl Definitions<'_>

source

pub fn json(&self) -> Result<String>

Generate a list of all functions in JSON format.

Functions from the following sources are included:

  1. Functions defined in an AST
  2. Functions registered into the global namespace
  3. Functions in static modules
  4. Functions in registered global packages
  5. Functions in standard packages (optional)

Trait Implementations§

source§

impl<'e> Clone for Definitions<'e>

source§

fn clone(&self) -> Definitions<'e>

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<'e> Debug for Definitions<'e>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'e> !RefUnwindSafe for Definitions<'e>

§

impl<'e> !Send for Definitions<'e>

§

impl<'e> !Sync for Definitions<'e>

§

impl<'e> Unpin for Definitions<'e>

§

impl<'e> !UnwindSafe for Definitions<'e>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.