Trait mica::ForeignFunction
source · pub trait ForeignFunction<V> {
type ParameterCount;
const PARAMETER_COUNT: Self::ParameterCount;
fn into_raw_foreign_function(self) -> RawForeignFunction;
}
Expand description
A Rust function that can be called from Mica.
To spare you the time needed to decipher the absolutely unreadable autogenerated implementations of this trait, functions with the following signatures are supported:
- Constant number of type checked arguments
fn (A, B, C, ...) -> R
where- Each argument:
TryFromValue
R
:Into
<
Value
>
- Each argument:
fn (A, B, C, ...) -> Result<R, E>
- Each argument:
TryFromValue
R
:Into
<
Value
>
- Each argument:
fn (Self, A, B, C, ...) -> R
whereSelf
:SelfFromRawValue
orMutSelfFromRawValue
- Each argument after
Self
:TryFromValue
R
:Into
<
Value
>
fn (Self, A, B, C, ...) -> Result<R, E>
Self
:SelfFromRawValue
orMutSelfFromRawValue
- Each argument after
Self
:TryFromValue
R
:Into
<
Value
>
- Due to a limitation in Rust’s type system, a maximum of 8 arguments is supported now. If more is needed, use the varargs versions described below.
- Variable number of dynamically typed arguments
The generic parameter V
is not used inside the trait. Its only purpose is to allow for
multiple overlapping implementations of a trait for the same type. See ffvariants
for more
information.
Required Associated Types§
sourcetype ParameterCount
type ParameterCount
The type used for parameter counts in this kind of foreign functions.
This is either FunctionParameterCount
or MethodParameterCount
, depending on whether
a function is usable as a bare function or a method.
Required Associated Constants§
sourceconst PARAMETER_COUNT: Self::ParameterCount
const PARAMETER_COUNT: Self::ParameterCount
The number of parameters this function has, or None
if the function accepts a variable
number of arguments.
The default implementation returns None
.
Required Methods§
sourcefn into_raw_foreign_function(self) -> RawForeignFunction
fn into_raw_foreign_function(self) -> RawForeignFunction
Converts the function to a RawForeignFunction
.