pub struct Function { /* private fields */ }Expand description
A callable unit: a signature plus a body.
See the module docs.
Implementations§
Source§impl Function
impl Function
Sourcepub fn new(signature: FunctionSignature, body: FunctionBody) -> Self
pub fn new(signature: FunctionSignature, body: FunctionBody) -> Self
Pairs a signature with a body.
Sourcepub fn signature(&self) -> &FunctionSignature
pub fn signature(&self) -> &FunctionSignature
Returns the signature.
Sourcepub fn invoke(&self, context: &mut Context, registry: &Registry)
pub fn invoke(&self, context: &mut Context, registry: &Registry)
Runs the function on data already on the stack.
Arguments must be pushed in reverse order beforehand, and results are left on the stack. Registers are scoped around the body, so the callee cannot reach the caller’s.
Sourcepub fn call<O: DataStackPack, I: DataStackPack>(
&self,
context: &mut Context,
registry: &Registry,
inputs: I,
verify: bool,
) -> O
pub fn call<O: DataStackPack, I: DataStackPack>( &self, context: &mut Context, registry: &Registry, inputs: I, verify: bool, ) -> O
Runs the function with Rust values, taking care of stack order.
With verify set, argument and result types are checked against the
signature first.
§Panics
Panics when verify is set and the types do not match, or when the
results on the stack are not of type O.
Sourcepub fn verify_inputs_outputs<O: DataStackPack, I: DataStackPack>(&self)
pub fn verify_inputs_outputs<O: DataStackPack, I: DataStackPack>(&self)
Checks that I and O match the signature.
§Panics
Panics with a message naming the offending parameter when they do not.
Sourcepub fn into_handle(self) -> FunctionHandle
pub fn into_handle(self) -> FunctionHandle
Wraps this function in a shared handle.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Function
impl !UnwindSafe for Function
impl Freeze for Function
impl Send for Function
impl Sync for Function
impl Unpin for Function
impl UnsafeUnpin for Function
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
Mutably borrows from an owned value. Read more