Skip to main content

Function

Struct Function 

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

A callable unit: a signature plus a body.

See the module docs.

Implementations§

Source§

impl Function

Source

pub fn new(signature: FunctionSignature, body: FunctionBody) -> Self

Pairs a signature with a body.

Source

pub fn signature(&self) -> &FunctionSignature

Returns the signature.

Source

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.

Source

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.

Source

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.

Source

pub fn into_handle(self) -> FunctionHandle

Wraps this function in a shared handle.

Trait Implementations§

Source§

impl Debug for Function

Source§

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

Formats the value using the given formatter. Read more

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> Finalize for T

Source§

unsafe fn finalize_raw(data: *mut ())

Drops the value stored at data in place. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.