#wolfram #wolfram-language #wolfram-engine #mathlink


Bindings to the Wolfram Symbolic Transfer Protocol (WSTP)

13 releases

0.2.9 Oct 7, 2023
0.2.7 Feb 4, 2023
0.2.4 Oct 20, 2022
0.2.2 May 18, 2022
0.2.1 Mar 4, 2022

#148 in Encoding

Download history 19/week @ 2023-07-18 39/week @ 2023-07-25 13/week @ 2023-08-01 22/week @ 2023-08-08 34/week @ 2023-08-15 42/week @ 2023-08-22 29/week @ 2023-08-29 49/week @ 2023-09-05 18/week @ 2023-09-12 23/week @ 2023-09-19 25/week @ 2023-09-26 62/week @ 2023-10-03 47/week @ 2023-10-10 52/week @ 2023-10-17 64/week @ 2023-10-24 90/week @ 2023-10-31

257 downloads per month
Used in 3 crates (2 directly)


69K SLoC


Crates.io License Documentation

API Documentation | Changelog | Contributing

Bindings to the Wolfram Symbolic Transfer Protocol (WSTP).

This crate provides a set of safe and ergonomic bindings to the WSTP library, used to transfer Wolfram Language expressions between programs.

Quick Examples

Write an expression to a loopback Link, and then read it back from the same link object:

use wstp::Link;

fn example() -> Result<(), wstp::Error> {
    let mut link = Link::new_loopback()?;

    // Write the expression {"a", "b", "c"}
    link.put_function("System`List", 3)?;

    // Read back the expression, concatenating the elements as we go:
    let mut buffer = String::new();

    for _ in 0 .. link.test_head("System`List")? {

    assert_eq!(buffer, "abc");



Transfer the expression "hello!" from one Link endpoint to another:

use wstp::Protocol;

let (mut a, mut b) = wstp::channel(Protocol::SharedMemory).unwrap();


assert_eq!(b.get_string().unwrap(), "hello!");

See wolfram-library-link for examples of using WSTP links to transfer expressions to and from LibraryLink functions.

Building wstp

The wstp crate uses wolfram-app-discovery to locate a local installation of the Wolfram Language that contains a suitable copy of the WSTP SDK. If the WSTP SDK cannot be located, wstp will fail to build.

If you have installed the Wolfram Language to a location unknown to wolfram-app-discovery, you may specify the installed location manually by setting the WOLFRAM_APP_DISCOVERY environment variable. See Configuring wolfram-app-discovery for details.

  • wolfram-library-link — author libraries that can be dynamically loaded by the Wolfram Language
  • wolfram-expr — efficient and ergonomic representation of Wolfram expressions in Rust.
  • wolfram-app-discovery — utility for locating local installations of Wolfram applications and the Wolfram Language.

Developer Notes

See Development.md for instructions on how to perform common development tasks when contributing to the wstp crate.

See Maintenance.md for instructions on how to keep wstp up to date as new versions of the Wolfram Language are released.


Licensed under either of

at your option.

Note: Licensing of the WSTP library linked by the wstp crate is covered by the terms of the MathLink License Agreement.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

See CONTRIBUTING.md for more information.


~74K SLoC