Struct TypeMeta

Source
pub struct TypeMeta { /* private fields */ }
Expand description

An introspection metadata for the Rust type registered by the Script Engine.

You cannot create this object manually; its creation is managed by the Script Engine. However, you can obtain a 'static reference to this object using the ScriptType::type_meta function and other related API functions.

The Display implementation prints the user-facing name of the type (e.g., "usize", "str", or "Vec<bool>").

This object allows you to explore the type’s introspection metadata and the Script operations available for this type using the TypeMeta::prototype function.

Implementations§

Source§

impl TypeMeta

Source

pub fn prototype(&self) -> &'static Prototype

Returns a Prototype of the Rust type that describes the script operations available for this type.

Source

pub fn instantiate(&'static self, origin: Origin) -> RuntimeResult<Cell>

Creates an instance of this type using the default constructor.

The function returns RuntimeError if the default constructor is not exported for this type, or if the constructor’s implementation returns a RuntimeError.

Source

pub fn concat( &'static self, origin: Origin, items: &mut [Arg], ) -> RuntimeResult<Cell>

Creates an array of objects by concatenating the data in items into a single slice in the resulting Cell.

The items source array does not necessarily have to be an array of objects of the same type. The underlying implementation may attempt to cast them into other types. The source array may also contain “gaps” (Nil Cells) and Cells with arrays. In this case, the canonical implementation of this operator typically flattens these sub-arrays. Additionally, the canonical implementation usually takes Arg objects from the items source slice.

The origin parameter specifies the Rust or Script source code range that spans the operator (e.g., the script array declaration).

The function returns a RuntimeError if the type does not support the “concat” operator, or if the operator’s implementation returns a RuntimeError.

Source§

impl TypeMeta

Source

pub fn nil() -> &'static Self

Returns the metadata of the unit () type. In Ad Astra terminology, the unit type is referred to as the “nil type” and represents inaccessible data.

The Nil Cell corresponds to the Nil type.

This function is a shortcut for <()>::type_meta().

Source

pub fn dynamic() -> &'static Self

Returns the metadata of the type placeholder that cannot be analyzed at script compile-time.

This function is a shortcut for <DynamicType>::type_meta().

Source

pub fn id(&self) -> &TypeId

Returns the TypeId of the original Rust type.

Source

pub fn is_nil(&self) -> bool

Returns true if this type is a Nil type, which represents a void, inaccessible object.

Source

pub fn is_dynamic(&self) -> bool

Returns true if the type is a Dynamic type, a type placeholder that cannot be analyzed at script compile-time.

Source

pub fn is_fn(&self) -> bool

Returns true if this type belongs to the family of functions.

These types typically support the invocation operator.

This function is a shortcut for type_meta_family().is_fn().

Source

pub fn name(&self) -> &'static str

Returns the user-facing name of the original Rust type, such as "usize", "str", "Vec<bool>", etc.

Source

pub fn origin(&self) -> &'static RustOrigin

Returns the location in the Rust source code where the Rust type was declared (or registered by the export macro).

Source

pub fn doc(&self) -> Option<&'static str>

Returns the RustDoc documentation for the Rust type.

The function returns None if the type does not have documentation or if the documentation was not recognized by the export macro.

Source

pub fn family(&self) -> &TypeFamily

Returns a reference to the family of types to which this Rust type belongs.

Trait Implementations§

Source§

impl Clone for TypeMeta

Source§

fn clone(&self) -> TypeMeta

Returns a duplicate 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 TypeMeta

Source§

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

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

impl Default for &'static TypeMeta

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for TypeMeta

Source§

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

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

impl From<&'static TypeMeta> for TypeHint

Source§

fn from(value: &'static TypeMeta) -> Self

Converts to this type from the input type.
Source§

impl Hash for TypeMeta

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for TypeMeta

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<TypeId> for TypeMeta

Source§

fn eq(&self, other: &TypeId) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for TypeMeta

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for TypeMeta

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for TypeMeta

Source§

impl Eq for TypeMeta

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToCompactString for T
where T: Display,

Source§

fn to_compact_string(&self) -> CompactString

Converts the given value to a CompactString. Read more
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§

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.