{"id":13801641,"url":"https://github.com/zero-deps/proto","last_synced_at":"2025-05-13T11:31:31.184Z","repository":{"id":41133931,"uuid":"175825220","full_name":"zero-deps/proto","owner":"zero-deps","description":"Lightweight and fast serialization library for Scala 2/3 based on Protocol Buffers with macros","archived":false,"fork":false,"pushed_at":"2024-09-21T15:43:43.000Z","size":6445,"stargazers_count":34,"open_issues_count":0,"forks_count":3,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-11-18T16:57:39.225Z","etag":null,"topics":["macros","protobuf","scala"],"latest_commit_sha":null,"homepage":"","language":"Scala","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/zero-deps.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-15T13:27:19.000Z","updated_at":"2024-09-20T21:37:44.000Z","dependencies_parsed_at":"2024-05-30T10:06:50.497Z","dependency_job_id":"cfd3144f-b5f6-4bb6-af8c-0f3063aeb820","html_url":"https://github.com/zero-deps/proto","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-deps%2Fproto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-deps%2Fproto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-deps%2Fproto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-deps%2Fproto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zero-deps","download_url":"https://codeload.github.com/zero-deps/proto/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253932900,"owners_count":21986473,"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":["macros","protobuf","scala"],"created_at":"2024-08-04T00:01:25.251Z","updated_at":"2025-05-13T11:31:28.655Z","avatar_url":"https://github.com/zero-deps.png","language":"Scala","readme":"# proto\n\n[![proto Scala version support](https://index.scala-lang.org/zero-deps/proto/proto/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/zero-deps/proto/proto)  \n[![proto Scala version support](https://index.scala-lang.org/zero-deps/proto/proto/latest-by-scala-version.svg?platform=sjs1)](https://index.scala-lang.org/zero-deps/proto/proto)  \n[![proto Scala version support](https://index.scala-lang.org/zero-deps/proto/proto/latest-by-scala-version.svg?platform=native0.5)](https://index.scala-lang.org/zero-deps/proto/proto)  \n![Production Ready](https://img.shields.io/badge/Project%20Stage-Production%20Ready-brightgreen.svg)\n\nLightweight and fast serialization library for Scala 2/3 based on Protocol Buffers with macros magic.\n\n## Motivation\n\nSerialization library for Scala that can be used either for long term store models and short term models.\nWith easy to migrate possibility.\n\n- Lightweight\n- Fast\n- Protocol Buffers compatible\n- No .proto files\n- No model convertation\n- Type safe\n- Serialization/deserialization without changes in models\n- Possibility to use specific types in model\n\n## Install\n\nAdd dependency:\n```\nlibraryDependencies += \"io.github.zero-deps\" %% \"proto\" % \"latest.integration\"\n```\n\nDependency as a git-submodule is also supported.\n\n## Benchmark #1\n\ndata |        | library        | scala-2        | scala-3\n---- | ------ |:-------------- | -------------: | ------------:\ndata | decode | java           | `   44079.139` | `  38979.697`\ndata | decode | jackson        | `  176941.468` | ` 188555.562`\ndata | decode | jsoniter-scala | `  483788.001` | no support for Scala 3\ndata | decode | boopickle      | ` 2885610.648` | no support for Scala 3\ndata | decode | proto          | ` 3383845.458` | `3776688.591`\ndata | decode | scalapb        | ` 3270691.564` | `3893847.420`\n\ndata |        | library        | scala-2        | scala-3\n---- | ------ |:-------------- | -------------: | ------------:\ndata | encode | java           | `  220444.268` | ` 217484.396`\ndata | encode | jackson        | `  431318.803` | ` 384863.249`\ndata | encode | jsoniter-scala | ` 1054650.233` | no support for Scala 3\ndata | encode | boopickle      | ` 1520834.519` | no support for Scala 3\ndata | encode | proto          | ` 3186951.441` | `2965427.382`\ndata | encode | scalapb        | ` 3628779.864` | `3972905.402`\n\ndata |        | library        | scala-2        | scala-3\n---- | ------ |:-------------- | -------------: | ------------:\nmsg  | decode | jsoniter-scala | ` 3486552.303` | no support for Scala 3\nmsg  | decode | proto          | ` 5825174.170` | `6395557.251`\nmsg  | decode | scalapb        | ` 4898257.671` | `6902064.854`\n\ndata |        | library        | scala-2        | scala-3\n---- | ------ |:-------------- | -------------: | ------------:\nmsg  | encode | jsoniter-scala | ` 6372602.760` | no support for Scala 3\nmsg  | encode | proto          | ` 6487748.959` | `6745673.393`\nmsg  | encode | scalapb        | ` 9202135.451` | `9056962.541`\n\n### environment\n\nIntel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz\\\n16 GB 2133 MHz LPDDR3\\\nJava 15\n\n### run benchmark\n\n```bash\nsbt\nproject bench\n++ 3.0.0\njmh:run -i 2 -wi 1 -f1 -t1\n```\n\n## Benchmark #2\n\ndata |        | library        | scala-3\n---- | ------ |:-------------- | -------------:\ndata | decode | java           | `   92130,460`\ndata | decode | jackson        | `  517036,354`\ndata | decode | proto          | ` 6716619,956`\n\ndata |        | library        | scala-3\n---- | ------ |:-------------- | -------------:\ndata | encode | java           | `  537462,511`\ndata | encode | jackson        | `  882065,311`\ndata | encode | proto          | ` 9380874,587`\n\ndata |        | library        | scala-3\n---- | ------ |:-------------- | -------------:\nmsg  | decode | proto          | `11733555,275`\n\ndata |        | library        | scala-3\n---- | ------ |:-------------- | -------------:\nmsg  | encode | proto          | `18486833,582`\n\n### environment\n\nApple M1\\\n16 GB\\\nJava 21\n\n### run benchmark\n\n```bash\nsbt\nproject bench\n++ 3.0.0\njmh:run -i 2 -wi 1 -f1 -t1\n```\n\n## Usage\n\nYou can pick one of the way how to define field number:\n- with annotation `@proto.N` and use `caseCodecAuto`\n- explicitly specify nums `caseCodecNums(Symbol(\"field1\")-\u003e1, Symbol(\"field2\")-\u003e2)`\n- field numbers by index `caseCodecIdx`\n\nYou can use annotation `@proto.RestrictedN` to restrict usage of specified field numbers. Can be used with classes or traits.\n\n```scala\nimport scala.collection.immutable.TreeMap\nimport proto.{encode, decode, N}\nimport proto.{caseCodecIdx, caseCodecNums, caseCodecAuto}\n\nfinal case class VectorClock(versions: TreeMap[String, Long])\n@RestrictedN(3,4)\nfinal case class Equipment(@N(1) id: String, @N(2) tpe: String)\nfinal case class Car(id: String, color: Int, equipment: List[Equipment], vc: VectorClock)\n\nimplicit val tuple2Codec = caseCodecIdx[Tuple2[String, Long]] //codec for TreeMap[String, Long]\n\nimplicit val vectorClockCodec = caseCodecIdx[VectorClock]\nimplicit val equipmentCodec = caseCodecAuto[Equipment]\nimplicit val carCodec = caseCodecNums[Car]('id-\u003e1, 'color-\u003e4, 'equipment-\u003e2, 'vc-\u003e3)\n\nval vc = VectorClock(versions=TreeMap.empty)\nval equipment = List(Equipment(id=\"1\", tpe=\"123\"), Equipment(id=\"2\", tpe=\"456\"))\nval car = Car(id=\"1\", color=16416882, equipment=equipment, vc=vc)\n//encode\nval bytes: Array[Byte] = encode(car)\n//decode\nval car2: Car = decode[Car](bytes)\n```\n\nMore examples in [testing.scala](src/test/scala/testing.scala)\n","funding_links":[],"categories":["Table of Contents"],"sub_categories":["Serialization"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzero-deps%2Fproto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzero-deps%2Fproto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzero-deps%2Fproto/lists"}