Skip to main content

HostFunction

Trait HostFunction 

Source
pub trait HostFunction<Arguments, Return>:
    HostFunctionAdapter<Arguments, Return>
    + Send
    + Sync
    + 'static { }
Expand description

A Rust function that can be registered as a Geam host function.

Owned host functions accept zero through seven scalar arguments. Supported Rust values are BigInt, f64, EcoString, BitArrayValue, char, bool, and (). A host function returns one value from the same set, or Infallible when it cannot return successfully.

Scoped host functions use the same arity boundary with the typed HostTypeParameter, HostListType, HostTupleType, and HostCustomType language. Their compound values remain borrowed through one HostCall.

use geam_core::HostModule;
use num_bigint::BigInt;

let _ = HostModule::new("host_support", "host/math")
    .unwrap()
    .with_function(
        "too_many",
        |_: BigInt,
         _: BigInt,
         _: BigInt,
         _: BigInt,
         _: BigInt,
         _: BigInt,
         _: BigInt,
         _: BigInt|
         -> BigInt { 0.into() },
    );
use geam_core::HostModule;

let _ = HostModule::new("host_support", "host/math")
    .unwrap()
    .with_function("unsupported", |value: i64| value);

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<Function, Arguments, Return> HostFunction<Arguments, Return> for Function
where Function: HostFunctionAdapter<Arguments, Return> + Send + Sync + 'static,