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
impl TypeMeta
Sourcepub fn prototype(&self) -> &'static Prototype
pub fn prototype(&self) -> &'static Prototype
Returns a Prototype of the Rust type that describes the script operations available for this type.
Sourcepub fn instantiate(&'static self, origin: Origin) -> RuntimeResult<Cell>
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.
Sourcepub fn concat(
&'static self,
origin: Origin,
items: &mut [Arg],
) -> RuntimeResult<Cell>
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
impl TypeMeta
Sourcepub fn dynamic() -> &'static Self
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()
.
Sourcepub fn is_nil(&self) -> bool
pub fn is_nil(&self) -> bool
Returns true if this type is a Nil type, which represents a void, inaccessible object.
Sourcepub fn is_dynamic(&self) -> bool
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.
Sourcepub fn is_fn(&self) -> bool
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()
.
Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
Returns the user-facing name of the original Rust type, such as
"usize"
, "str"
, "Vec<bool>"
, etc.
Sourcepub fn origin(&self) -> &'static RustOrigin
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).
Sourcepub fn doc(&self) -> Option<&'static str>
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.
Sourcepub fn family(&self) -> &TypeFamily
pub fn family(&self) -> &TypeFamily
Returns a reference to the family of types to which this Rust type belongs.
Trait Implementations§
Source§impl Ord for TypeMeta
impl Ord for TypeMeta
Source§impl PartialOrd for TypeMeta
impl PartialOrd for TypeMeta
impl Copy for TypeMeta
impl Eq for TypeMeta
Auto Trait Implementations§
impl Freeze for TypeMeta
impl RefUnwindSafe for TypeMeta
impl Send for TypeMeta
impl Sync for TypeMeta
impl Unpin for TypeMeta
impl UnwindSafe for TypeMeta
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString
. Read more