Expand description
Unified runtime for #[export]-marked Wolfram LibraryLink functions.
Pick modes via Cargo features:
wolfram-export = { version = "0.5", features = ["wxf"] } # typed WXF
wolfram-export = { version = "0.5", features = ["wstp"] } # WSTP Link
wolfram-export = "0.5" # native + margs (default)#[export(margs)] (raw MArgument, manual marshaling) rides on the
native feature — there’s no separate feature flag for it.
Then in your code (shown here with every mode enabled):
use wolfram_export::{export, sys::MArgument, wstp::Link};
#[export] fn add(a: f64, b: f64) -> f64 { a + b }
#[export(margs)] fn raw_add(args: &[MArgument], ret: MArgument) {
unsafe { *ret.real = *args[0].real + *args[1].real; }
}
#[export(wstp)] fn echo(link: &mut Link) { let _ = link; }
#[export(wxf)] fn dot(a: Vec<f64>, b: Vec<f64>) -> f64 {
a.iter().zip(&b).map(|(x, y)| x * y).sum()
}Each mode’s wire shape, runtime, and Cargo dep set live in its own
feature-gated submodule below. The ExportEntry inventory and the
__wolfram_manifest__ C symbol are always on (they’re tiny and how the
cargo wl build tool discovers exports).
Modules§
- macro_
utils - Macro-runtime helpers. Re-exports of the per-mode
macro_utilsmodules behind a singlewolfram_export::macro_utils::*namespace so the proc-macro can emit one consistent path regardless of mode. - native
- Runtime support for native-mode exports (
#[export]), which are called over the rawMArgumentC ABI. Runtime support for#[export]-marked native (MArgument-based) LibraryLink functions. - sys
- Raw
wolfram-library-link-sysC-FFI types (WolframLibraryData,MArgument,mint, …). Available whenever any LibraryLink-using mode is enabled.
Enums§
- Export
Entry - Inventory entry for one
#[export]-marked function.
Traits§
- Native
Function - Trait implemented for any function whose parameters and return type are native
LibraryLink
MArgumenttypes.
Functions§
- exported_
library_ functions_ association - Returns an
Associationcontaining the names andLibraryFunctionLoadcalls for every#[export(..)]-marked function in this library.
Attribute Macros§
- export
- Export a function as a Wolfram LibraryLink function. See
exportfor the four wire-format modes (native,margs,wstp,wxf) and the Cargo features each one needs. Export a function as a Wolfram LibraryLink function, in one of four wire formats picked by a keyword argument. All four needLibraryFunctionLoadon the Wolfram side and none of them need theautomate-function-loading-boilerplatefeature to work — that feature only affects whethercargo wl buildcan discover the load call for you (#[export(margs)]needs anargs =/ret =annotation for that discovered call to be correct — see below). - init
- Designate a one-time library-load initialization function. See
init. Designate an initialization function to run once, when this library is loaded via Wolfram LibraryLink — distinct from [export], which wraps a function called on every invocation from Wolfram.