Function rustler_elixir_fun::apply_elixir_fun
source · [−]pub fn apply_elixir_fun<'a>(
env: Env<'a>,
pid_or_name: Term<'a>,
fun: Term<'a>,
parameters: Term<'a>
) -> Result<Term<'a>, Error>
Expand description
Will run fun
with the parameters parameters
on the process indicated by pid_or_name
.
On success, returns an Ok result whose content is a term which might be one of:
{:ok, some_term}
on a successfull function call.{:error, {:exception, some_exception}}
if the functionraise
d an exception.{:error, {:exit, exit_message}}
if an exit was caught.{:error, {:throw, value}}
if a value wasthrow
n.
Raises an ArgumentError (e.g. returns Err(Error::BadArg)
on the Rust side) if fun
is not a function or parameters
is not a list.
Notes
- Be sure to register any NIF that calls this function as a ‘Dirty CPU NIF’! (by using
#[rustler::nif(schedule = "DirtyCpu")]
). This is important for two reasons:- calling back into Elixir might indeed take quite some time.
- we want to prevent schedulers to wait for themselves, which might otherwise sometimes happen.