chore: generate a rustler project

Signed-off-by: SphericalKat <amolele@gmail.com>
This commit is contained in:
sphericalkat committed 2021-08-16 13:58:58 +05:30
1 parent 478bea7efb
commit 024b8a7c64
7 files changed
+48

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
+1
View File
@@ -0,0 +1 @@
/target
+13
View File
@@ -0,0 +1,13 @@
[package]
name = "ketbin_utils_syntax"
version = "0.1.0"
authors = []
edition = "2018"
[lib]
name = "ketbin_utils_syntax"
path = "src/lib.rs"
crate-type = ["cdylib"]
[dependencies]
rustler = "0.22.0"
+20
View File
@@ -0,0 +1,20 @@
# NIF for Elixir.Ketbin.Utils.Syntax
## To build the NIF module:
- Your NIF will now build along with your project.
## To load the NIF:
```elixir
defmodule Ketbin.Utils.Syntax do
use Rustler, otp_app: :ketbin, crate: "ketbin_utils_syntax"
# When your NIF is loaded, it will override this function.
def add(_a, _b), do: :erlang.nif_error(:nif_not_loaded)
end
```
## Examples
[This](https://github.com/hansihe/NifIo) is a complete example of a NIF written in Rust.
+6
View File
@@ -0,0 +1,6 @@
#[rustler::nif]
fn add(a: i64, b: i64) -> i64 {
a + b
}
rustler::init!("Elixir.Ketbin.Utils.Syntax", [add]);