Skip to main content

IntoHostFn

Trait IntoHostFn 

pub trait IntoHostFn<Marker> {
    // Required method
    fn into_host_fn_parts(
        self,
    ) -> (Rc<dyn Fn(&[Value]) -> Value>, Vec<HostType>, HostType);
}
Expand description

Adapts a Rust closure into a registered host function.

The Marker type parameter disambiguates the blanket impls by arity (and, for &str, by borrow), the same trick rhai/bevy use to make register_fn accept closures of many shapes without annotations.

Required Methods§

fn into_host_fn_parts( self, ) -> (Rc<dyn Fn(&[Value]) -> Value>, Vec<HostType>, HostType)

Internal adapter: yields the erased dispatcher plus the argument and return type signature derived from the closure. Not meant to be called directly; Engine::register_host_fn drives it.

Implementors§

§

impl<F, R> IntoHostFn<Arity0> for F
where F: Fn() -> R + 'static, R: IntoHostValue,

§

impl<F, R> IntoHostFn<ArityStr1> for F
where F: Fn(&str) -> R + 'static, R: IntoHostValue,

§

impl<F, R, A0> IntoHostFn<(A0,)> for F
where F: Fn(A0) -> R + 'static, R: IntoHostValue, A0: FromHostValue + 'static,

§

impl<F, R, A0, A1> IntoHostFn<(A0, A1)> for F
where F: Fn(A0, A1) -> R + 'static, R: IntoHostValue, A0: FromHostValue + 'static, A1: FromHostValue + 'static,

§

impl<F, R, A0, A1, A2> IntoHostFn<(A0, A1, A2)> for F
where F: Fn(A0, A1, A2) -> R + 'static, R: IntoHostValue, A0: FromHostValue + 'static, A1: FromHostValue + 'static, A2: FromHostValue + 'static,

§

impl<F, R, A0, A1, A2, A3> IntoHostFn<(A0, A1, A2, A3)> for F
where F: Fn(A0, A1, A2, A3) -> R + 'static, R: IntoHostValue, A0: FromHostValue + 'static, A1: FromHostValue + 'static, A2: FromHostValue + 'static, A3: FromHostValue + 'static,

§

impl<F, R, A0, A1, A2, A3, A4> IntoHostFn<(A0, A1, A2, A3, A4)> for F
where F: Fn(A0, A1, A2, A3, A4) -> R + 'static, R: IntoHostValue, A0: FromHostValue + 'static, A1: FromHostValue + 'static, A2: FromHostValue + 'static, A3: FromHostValue + 'static, A4: FromHostValue + 'static,