Skip to content

An example of Clojure program calling a Rust library, all combined into one executable using GraalVM.

License

Notifications You must be signed in to change notification settings

borkdude/clojure-rust-graalvm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

An example of Clojure program calling a Rust library, all combined into one executable using GraalVM.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published