Trait ScriptPackage

Source
pub trait ScriptPackage {
    // Required method
    fn meta() -> &'static PackageMeta;

    // Provided methods
    fn origin() -> &'static RustOrigin { ... }
    fn name() -> &'static str { ... }
    fn version() -> &'static str { ... }
}
Expand description

A type that represents the Script Package of a crate.

This trait is automatically implemented on a struct type when you export it as a crate package.

Through the ScriptPackage::meta function, you gain access to the PackageMeta object. This can be used, for example, to instantiate new script modules that can be analyzed in accordance with the exported semantics of the crate or to run an LSP server.

use ad_astra::{export, runtime::ScriptPackage};

#[export(package)]
#[derive(Default)]
struct Package;

assert_eq!(Package::meta().name(), "ad-astra");

Required Methods§

Source

fn meta() -> &'static PackageMeta

Returns a reference to the full metadata object of the crate’s package.

Provided Methods§

Source

fn origin() -> &'static RustOrigin

Returns a Rust source code location that points to where the package type was declared.

This is a shortcut for PackageMeta::origin.

Source

fn name() -> &'static str

Returns the name of the package’s crate.

This is a shortcut for PackageMeta::name.

Source

fn version() -> &'static str

Returns the version of the package’s crate.

This is a shortcut for PackageMeta::version.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§