Skip to main content

LumenFn

Type Alias LumenFn 

Source
pub type LumenFn = unsafe extern "C" fn(out: *mut LumenValue, argc: c_int, argv: *const LumenValue, user_data: *mut c_void);
Expand description

Signature of an exposed callback. Register with lumen_app_expose.

The result travels through the out pointer rather than a by-value return. LumenValue is larger than the 16-byte register-pair threshold, so returning it by value forces every non-Rust binding to hand-encode the platform’s aggregate-return (SysV sret) convention; an out-parameter is expressible in ctypes, libffi, and every other binding layer without target-specific code.

out is never null when Lumen invokes the callback, and points to a single writable LumenValue that Lumen has zero-initialised to LumenKind::Nil, so a callback that wants to return nil may leave it untouched.

argv is borrowed for the duration of the call. Lumen reads *out into a Dynamic once the callback returns, so any pointers the written value carries must outlive the call rather than point into the callback’s own frame; static or heap storage the callback owns works, a local buffer does not.