chore: generate a rustler project
Signed-off-by: SphericalKat <amolele@gmail.com>
This commit is contained in:
7 files changed
+48
No files matched your search
@@ -0,0 +1,5 @@
|
||||
[target.x86_64-apple-darwin]
|
||||
rustflags = [
|
||||
"-C", "link-arg=-undefined",
|
||||
"-C", "link-arg=dynamic_lookup",
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
/target
|
||||
@@ -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"
|
||||
@@ -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.
|
||||
@@ -0,0 +1,6 @@
|
||||
#[rustler::nif]
|
||||
fn add(a: i64, b: i64) -> i64 {
|
||||
a + b
|
||||
}
|
||||
|
||||
rustler::init!("Elixir.Ketbin.Utils.Syntax", [add]);
|
||||
Reference in new issue
Block a user