Skip to main content

Crate wolfram_export

Crate wolfram_export 

Source
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 (default)

Then in your code:

use wolfram_export::export;

#[export]                  fn add(a: f64, b: f64) -> f64 { a + b }
#[export(wstp)]            fn foo(link: &mut Link) { /* ... */ }
#[export(wxf)]             fn dot(a: Vec<f64>, b: Vec<f64>) -> f64 { /* ... */ }

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_utils modules behind a single wolfram_export::macro_utils::* namespace so the proc-macro can emit one consistent path regardless of mode.
native
Runtime support for #[export]-marked native (MArgument-based) LibraryLink functions.
sys
Raw wolfram-library-link-sys C-FFI types (WolframLibraryData, MArgument, mint, …). Available whenever any LibraryLink-using mode is enabled.

Enums§

ExportEntry
Inventory entry for one #[export]-marked function.

Traits§

NativeFunction
Trait implemented for any function whose parameters and return type are native LibraryLink MArgument types.

Functions§

exported_library_functions_association
Returns an Association containing the names and LibraryFunctionLoad calls for every #[export(..)]-marked function in this library.

Attribute Macros§

export
Back-compat #[export] / #[export(wstp)] proc-macro: dispatches by the wstp keyword in attrs. Used by the wolfram_library_link::export re-export so existing call sites compile unchanged — emitted code paths resolve through ::wolfram_library_link::*.
export_native
Annotate a function for export via the native (MArgument-based) Wolfram LibraryLink ABI. Re-exported by wolfram-export-native as export.
export_wstp
Annotate a function for export via the WSTP LinkObject ABI. Re-exported by wolfram-export-wstp as export.
export_wxf
Annotate a function for export via the WXF (typed-arg) ABI. The wrapper reads a ByteArray MArgument containing a WXF-encoded payload, deserializes via FromWolfram, calls the user function, serializes the return value, and writes a ByteArray MArgument back. Re-exported by wolfram-export-wxf as export.
init
Mark a function as the library’s WolframLibrary_initialize() entry point.