Skip to content

Latest commit

 

History

History
44 lines (29 loc) · 1.25 KB

README.md

File metadata and controls

44 lines (29 loc) · 1.25 KB

clojure-rust-graalvm

An example of Clojure program calling a Rust library, all combined into one executable using GraalVM. It gets the amount of free memory via the heim-rs library and prints it in EDN format.

This repo is an adapted example of what is described in the README of the Rust jni library.

In clojure/src-java there is a Java static method which calls a Rust function via JNI. We call this static method from Clojure.

Usage

$ time ./clojure-rust megabyte
{:memory/free [:megabyte "1210"]}
./clojure-rust megabyte   0.01s  user 0.01s system 34% cpu 0.027 total

Accepted options: byte, megabyte, gigabyte.

Build

Prerequisites:

Run script/compile to build the Rust lib, the Clojure uberjar and the GraalVM executable.

Finally, run the executable:

$ target/clojure-rust
{:memory/free [:byte "896126976"]}

License

Copyright © 2020 Michiel Borkent

Distributed under the EPL License, same as Clojure. See LICENSE.