{"id":43027987,"url":"https://github.com/jinganix/enif_protobuf","last_synced_at":"2026-01-31T07:11:13.251Z","repository":{"id":20231192,"uuid":"81412805","full_name":"jinganix/enif_protobuf","owner":"jinganix","description":"A Google Protobuf implementation with enif (Erlang nif)","archived":false,"fork":false,"pushed_at":"2023-12-29T03:29:01.000Z","size":1295,"stargazers_count":37,"open_issues_count":2,"forks_count":20,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-16T19:26:51.684Z","etag":null,"topics":["enif","erlang","google","nif","protobuf"],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jinganix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-09T05:29:58.000Z","updated_at":"2024-04-16T19:26:51.684Z","dependencies_parsed_at":"2023-01-12T03:30:20.930Z","dependency_job_id":null,"html_url":"https://github.com/jinganix/enif_protobuf","commit_stats":null,"previous_names":["jinganix/enif_protobuf","jg513/enif_protobuf"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jinganix/enif_protobuf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinganix%2Fenif_protobuf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinganix%2Fenif_protobuf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinganix%2Fenif_protobuf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinganix%2Fenif_protobuf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jinganix","download_url":"https://codeload.github.com/jinganix/enif_protobuf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinganix%2Fenif_protobuf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28932644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T04:05:25.756Z","status":"ssl_error","status_checked_at":"2026-01-31T04:02:35.005Z","response_time":128,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["enif","erlang","google","nif","protobuf"],"created_at":"2026-01-31T07:11:12.683Z","updated_at":"2026-01-31T07:11:13.246Z","avatar_url":"https://github.com/jinganix.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/jinganix/enif_protobuf/actions/workflows/ci.yml/badge.svg)](https://github.com/jinganix/enif_protobuf/actions/workflows/ci.yml)\n\n# enif_protobuf\nA Google Protobuf implementation with enif (Erlang nif).\n\nBase on gpb, see more info at\nhttps://github.com/tomas-abrahamsson/gpb\n\nBasic example of using epb\n--------------------------\n\nLet's say we have a protobuf file, `x.proto`\n```protobuf\nmessage Person {\n    required string name = 1;\n    required int32 id = 2;\n    optional string email = 3;\n}\n```\nWe can generate code for this definition in a number of different\nways. Here we use the command line tool.\n```shell\n# export GPB_PATH=/path/to/gpb\n# ${GPB_PATH}/bin/protoc-erl -I. x.proto\n```\nNow we've got `x.erl` and `x.hrl`. First we compile it.\n```shell\n# erlc -I${GPB_PATH}/include x.erl\n```\n\nThen we can try it out in the Erlang shell. When use rebar3, the `EPB_EBIN_PATH`\nis in `_build` directory.\n```erlang\n# export EPB_EBIN_PATH=/path/to/enif_protobuf/ebin\n# erl -pa ${EPB_EBIN_PATH}\nErlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false]\n\nEshell V7.3  (abort with ^G)\n1\u003e rr(\"x.hrl\").\n['Person']\n2\u003e Bin=x:encode_msg(#'Person'{name=\"abc def\", id=345, email=\"a@example.com\"}).\n\u003c\u003c10,7,97,98,99,32,100,101,102,16,217,2,26,13,97,64,101,\n  120,97,109,112,108,101,46,99,111,109\u003e\u003e\n3\u003e enif_protobuf:load_cache(x:get_msg_defs()).\nok\n4\u003e Bin=enif_protobuf:encode(#'Person'{name=\"abc def\", id=345, email=\"a@example.com\"}).\n\u003c\u003c10,7,97,98,99,32,100,101,102,16,217,2,26,13,97,64,101,\n  120,97,109,112,108,101,46,99,111,109\u003e\u003e\n5\u003e enif_protobuf:decode(Bin,'Person').\n#'Person'{name = \u003c\u003c\"abc def\"\u003e\u003e,id = 345,\n          email = \u003c\u003c\"a@example.com\"\u003e\u003e}\n6\u003e enif_protobuf:set_opts([{string_as_list, true}]).\nok\n7\u003e enif_protobuf:decode(Bin,'Person').\n#'Person'{name = \"abc def\",id = 345,email = \"a@example.com\"}\n8\u003e enif_protobuf:encode(#'Person'{name=\"你好\", id=345, email=\"a@example.com\"}).\n{error,[20320,22909]}\n9\u003e enif_protobuf:set_opts([{with_utf8, true}]).\nok\n10\u003e enif_protobuf:encode(#'Person'{name=\"你好\", id=345, email=\"a@example.com\"}).\n\u003c\u003c10,6,228,189,160,229,165,189,16,217,2,26,13,97,64,101,\n  120,97,109,112,108,101,46,99,111,109\u003e\u003e\n```\n\nPerformance\n-----------\n\nHere is a comparison between enif_protobuf(epb) and gpb\n\n    [MB/s]        | epb    | gpb   | gpb nif |\n    --------------+--------+-------+---------+\n    small msgs    |        |       |         |\n      serialize   | 116.09 | 32.17 |  38.02  |\n      deserialize | 111.88 | 35.57 |  61.87  |\n    --------------+--------+-------+---------+\n    large msgs    |        |       |         |\n      serialize   | 122.86 | 20.90 |  38.64  |\n      deserialize | 114.72 | 32.53 |  59.29  |\n    --------------+--------+-------+---------+\n\nHW info\n\n    CPU info\n    model name\t: Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz\n    cache size\t: 3072 KB\n    cores/threads   : 4\n    bogomips\t: 6585.04\n\n    Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 7.3\n\nThe performances are measured as number of processed MB/s, serialized form.  Higher values means better performance.\n\nThe benchmarks are run with small and large messages (228 and 84584 bytes, respectively, in serialized form)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjinganix%2Fenif_protobuf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjinganix%2Fenif_protobuf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjinganix%2Fenif_protobuf/lists"}