Skip to main content

HostFn

Trait HostFn 

Source
pub trait HostFn: Send + Sync {
    // Required method
    fn call(
        &self,
        cx: HostCallContext,
        input: Value,
    ) -> BoxFuture<'static, Result<Value, HostJsError>>;
}
Expand description

One function of a host library. Any Fn(HostCallContext, Value) -> impl Future<Output = Result<Value, HostJsError>> is one.

Required Methods§

Source

fn call( &self, cx: HostCallContext, input: Value, ) -> BoxFuture<'static, Result<Value, HostJsError>>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<F, Fut> HostFn for F
where F: Fn(HostCallContext, Value) -> Fut + Send + Sync, Fut: Future<Output = Result<Value, HostJsError>> + Send + 'static,