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§
Sourcefn meta() -> &'static PackageMeta
fn meta() -> &'static PackageMeta
Returns a reference to the full metadata object of the crate’s package.
Provided Methods§
Sourcefn origin() -> &'static RustOrigin
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.
Sourcefn name() -> &'static str
fn name() -> &'static str
Returns the name of the package’s crate.
This is a shortcut for PackageMeta::name.
Sourcefn version() -> &'static str
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.