pub struct InvocationMeta {
pub origin: Origin,
pub name: Option<&'static str>,
pub doc: Option<&'static str>,
pub receiver: Option<TypeHint>,
pub inputs: Option<Vec<Param>>,
pub output: TypeHint,
}
Expand description
Metadata for a function-like object.
Typically, this object describes the signatures of exported Rust functions and methods, but it can also describe a broader range of exported objects that support the invocation operation.
This object aids in the static semantic analysis of Script source code.
The Display implementation of this object renders a canonical, user-facing
view of the function’s signature, such as
fn foo(x: usize, y: bool) -> f32
.
Generally, you don’t need to instantiate this object manually, unless your crate introduces new types of invokable objects. In such cases, you should store this object in a static context.
use ad_astra::{
lady_deirdre::sync::Lazy,
runtime::{InvocationMeta, Origin, Param, ScriptType},
};
static INVOKE_META: Lazy<InvocationMeta> = Lazy::new(|| {
InvocationMeta {
name: Some("foo"),
inputs: Some(vec![Param {
name: None,
hint: <usize>::type_meta().into(),
}]),
..InvocationMeta::new(Origin::nil())
}
});
assert_eq!(INVOKE_META.name, Some("foo"));
Fields§
§origin: Origin
The source code range in Rust or Script where the function signature was introduced.
Typically, the resulting Origin points to the Rust code.
name: Option<&'static str>
The name of the function, if the function has a name.
doc: Option<&'static str>
The RustDoc documentation for this function, if available.
receiver: Option<TypeHint>
The type of the method’s receiver (e.g., self
, &self
, and
similar Rust function parameters), if the function has a receiver.
inputs: Option<Vec<Param>>
The signature of the function parameters, excluding the receiver, if the signature metadata is available.
output: TypeHint
The type of the object returned after the function invocation.
If the return type is not specified, the output
corresponds to the
TypeHint::dynamic.
Implementations§
Trait Implementations§
Source§impl Clone for InvocationMeta
impl Clone for InvocationMeta
Source§fn clone(&self) -> InvocationMeta
fn clone(&self) -> InvocationMeta
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for InvocationMeta
impl Debug for InvocationMeta
Source§impl Display for InvocationMeta
impl Display for InvocationMeta
Source§impl From<&'static InvocationMeta> for TypeHint
impl From<&'static InvocationMeta> for TypeHint
Source§fn from(value: &'static InvocationMeta) -> Self
fn from(value: &'static InvocationMeta) -> Self
Source§impl Hash for &'static InvocationMeta
impl Hash for &'static InvocationMeta
Source§impl PartialEq for &'static InvocationMeta
impl PartialEq for &'static InvocationMeta
impl Eq for &'static InvocationMeta
Auto Trait Implementations§
impl Freeze for InvocationMeta
impl RefUnwindSafe for InvocationMeta
impl Send for InvocationMeta
impl Sync for InvocationMeta
impl Unpin for InvocationMeta
impl UnwindSafe for InvocationMeta
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