Are there any good tutorials on how to use Rustler?

I’m looking for a good tutorial or documentation on how to use Rustler in a safe way. Everything I’ve found so far uses unwrap everywhere. I’d like to use NitfResult and convert my results into a rustler result, but I’m having a bit of trouble figuring it out.

Rustler’s documentation is basically void of any examples on how to use the library. There’s one example referenced in the docs but that repo is 6 years old and covers very little.

Thanks! :smiley:

1 Like

Check out this JSON library: rjs/lib.rs at master · yjh0502/rjs · GitHub

1 Like

Your best bet is taking inspiration from various Elixir projects using it, sadly.

In the last few months work on Rustler seems to have resumed so I hope we can expect a stable 0.22 version before the end of the year. This is important because 0.21 had pretty verbosive syntax requirements for the glue code and 0.22-rc introduced a much shorter and readable one.

This GitHub search can help send you in the right direction, hopefully.


EDIT: Interestingly enough (and I stand corrected), Rustler has a 0.22.0 GIT tag (and no GitHub release but that seems irrelevant?). But it does look like Rustler 0.22 is actually official, judging by its hex.pm page.

2 Likes

I was able to find this Medium article on getting started with Rustler.

Besides this, I do know that the maintainers are working on an improved page with more general guides next to the already-existing Elixir- and Rust module documentation pages. However, that seems to still be a ways off, unfortunately.

If you have any concrete questions, I’m sure we’ll be able to help you along here at the Elixir Forum. I’ve gone through the rodeo of making a NIF a couple of times now, and there are others who regularly use Rustler as well, so ask any questions you might have :smiley: .

2 Likes