{"id":28191617,"url":"https://github.com/modelfoxdotdev/erl_nif","last_synced_at":"2025-05-16T11:10:44.382Z","repository":{"id":57625717,"uuid":"377537201","full_name":"modelfoxdotdev/erl_nif","owner":"modelfoxdotdev","description":"Write Erlang/Elixir NIFs with Rust.","archived":false,"fork":false,"pushed_at":"2022-02-27T17:18:18.000Z","size":50,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-15T23:16:57.109Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/modelfoxdotdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-16T15:08:06.000Z","updated_at":"2024-01-15T00:07:36.000Z","dependencies_parsed_at":"2022-09-04T09:41:07.178Z","dependency_job_id":null,"html_url":"https://github.com/modelfoxdotdev/erl_nif","commit_stats":null,"previous_names":["tangramdotdev/erl_nif"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modelfoxdotdev%2Ferl_nif","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modelfoxdotdev%2Ferl_nif/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modelfoxdotdev%2Ferl_nif/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modelfoxdotdev%2Ferl_nif/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/modelfoxdotdev","download_url":"https://codeload.github.com/modelfoxdotdev/erl_nif/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518401,"owners_count":22084376,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-16T11:10:23.666Z","updated_at":"2025-05-16T11:10:44.375Z","avatar_url":"https://github.com/modelfoxdotdev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# erl_nif\n\nThis crate provides bindings to the [erl_nif](https://erlang.org/doc/man/erl_nif.html) C API, making it easy to write native extensions for Erlang and Elixir in Rust.\n\n## Example\n\nWrite your NIF in Rust:\n\n```rust\nerl_nif::init!(\n  name: \"Elixir.Add\",\n  funcs: [add],\n);\n\n#[erl_nif::nif]\nfn add(a: u64, b: u64) -\u003e Result\u003cu64, String\u003e {\n  Ok(a + b)\n}\n```\n\nThen load it in Elixir.\n\n```elixir\ndefmodule Add do\n  @on_load {:init, 0}\n  def init do\n    path = :filename.join(:code.priv_dir(:add), \"libadd\")\n    :ok = :erlang.load_nif(path, nil)\n  end\n\n  def add(_) do\n    :erlang.nif_error(:nif_not_loaded)\n  end\nend\n```\n\nSee the examples folder for a complete example.\n\n## Serde integration\n\nTo make it easy to move data structures between Rust and Elixir, the erl_nif crate supports integration with [serde](https://serde.rs).\n\n```rust\n#[derive(serde::Serialize, serde::Deserialize)]\n#[serde(rename = \"Elixir.Example.Contact\")]\nstruct Contact {\n  name: String,\n  email: String,\n}\n```\n\n```elixir\ndefmodule Example do\n  defmodule Contact do\n    defstruct [\n      :name,\n      :email\n    ]\n  end\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodelfoxdotdev%2Ferl_nif","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmodelfoxdotdev%2Ferl_nif","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodelfoxdotdev%2Ferl_nif/lists"}