pub struct ScriptSig {
pub params: Vec<ScriptParam>,
pub ret: ScriptTy,
pub variadic: bool,
pub min_arity: usize,
pub doc: String,
}Expand description
The declared signature of a ScriptFn.
Fields§
§params: Vec<ScriptParam>Positional parameters, in order.
ret: ScriptTyReturn type.
variadic: boolAccepts more arguments than Self::params declares.
min_arity: usizeSmallest accepted argument count. Parameters past it are optional and
arrive as ScriptValue::Unit when the call omits them.
doc: StringOne-line description, surfaced by editor tooling.
Implementations§
Source§impl ScriptSig
impl ScriptSig
Sourcepub fn arity_range(&self) -> RangeInclusive<usize>
pub fn arity_range(&self) -> RangeInclusive<usize>
The inclusive range of argument counts a host binds this signature for.
Sourcepub fn is_typed(&self) -> bool
pub fn is_typed(&self) -> bool
Whether any parameter declares a type.
An all-Any signature says nothing to check, so a host
that binds variadically passes whatever the script sent straight
through; that is what lumen_app_expose and the SDK’s native_fn
describe, and a call with the wrong count reaches the body rather than
failing to resolve. Dynamic says as little.
Sourcepub fn complete_args(&self, args: &[ScriptValue]) -> Option<Vec<ScriptValue>>
pub fn complete_args(&self, args: &[ScriptValue]) -> Option<Vec<ScriptValue>>
args with each struct argument’s missing fields
set to their defaults, or None when the signature takes no struct and
args stands as it is.
Sourcepub fn check_args(&self, args: &[ScriptValue]) -> Result<(), String>
pub fn check_args(&self, args: &[ScriptValue]) -> Result<(), String>
Check args against the declared parameters. Returns the message a host
raises to the script on a mismatch.
Too few arguments is a mismatch; extra arguments are one only when the
signature is not variadic. A parameter past Self::min_arity accepts
ScriptValue::Unit whatever its declared type, so a host that pads a
short call with unit placeholders still passes.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ScriptSig
impl<'de> Deserialize<'de> for ScriptSig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ScriptSig
impl RefUnwindSafe for ScriptSig
impl Send for ScriptSig
impl Sync for ScriptSig
impl Unpin for ScriptSig
impl UnsafeUnpin for ScriptSig
impl UnwindSafe for ScriptSig
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,
§impl<T> FromTemplate for T
impl<T> FromTemplate for T
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
§impl<T> Template for T
impl<T> Template for T
§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a [Template::Output].§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.