rustler | Safe Rust bridge for creating Erlang NIF functions | Authentication library
kandi X-RAY | rustler Summary
kandi X-RAY | rustler Summary
Documentation | Getting Started | Example. Rustler is a library for writing Erlang NIFs in safe Rust code. That means there should be no ways to crash the BEAM (Erlang VM). The library provides facilities for generating the boilerplate for interacting with the BEAM, handles encoding and decoding of Erlang terms, and catches rust panics before they unwind into C. The library provides functionality for both Erlang and Elixir, however Elixir is favored as of now. The easiest way of getting started is the rustler elixir library. NOTE: If you have previously used Rustler, you need to run mix archive.uninstall rustler_installer.ez to remove it before generating the NIF. This is the code for a minimal NIF that adds two numbers and returns the result. Rustler aims to support the newest three major OTP versions as well as newest three minor Elixir versions.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of rustler
rustler Key Features
rustler Examples and Code Snippets
Community Discussions
Trending Discussions on rustler
QUESTION
I'm in the process of writing a tutorial, because I couldn't find a simple example anywhere, of communicating between Elixir and Rust via a Port.
I can get Rustler to work, but that is a NIF, not a Port.
I'm missing something fundamental in my code. I'm not sure if I'm missing something basic in stdio or if it's something else, but I've tried a lot of different things.
I can get port communication to work with a very basic program in Rust:
...ANSWER
Answered 2017-May-18 at 14:31You're reading a line of input in the Rust code, which will read until a \r\n
or \n
, but you're not sending the newline character from Elixir. If you change all the Port.command
calls to add a \n
after the message, it works:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install rustler
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page