{"id":18113699,"url":"https://github.com/cemoktra/gin-tonic","last_synced_at":"2025-04-14T07:12:00.788Z","repository":{"id":245056488,"uuid":"813541912","full_name":"cemoktra/gin-tonic","owner":"cemoktra","description":"tonic with gin","archived":false,"fork":false,"pushed_at":"2025-01-07T07:29:31.000Z","size":1433,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-27T20:51:16.393Z","etag":null,"topics":["grpc","protobuf","tonic"],"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/cemoktra.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":"2024-06-11T09:24:33.000Z","updated_at":"2025-01-07T07:29:36.000Z","dependencies_parsed_at":"2024-06-19T12:25:45.665Z","dependency_job_id":"4369e6ee-e67d-462c-8290-8bb506eafe96","html_url":"https://github.com/cemoktra/gin-tonic","commit_stats":null,"previous_names":["cemoktra/gin-tonic"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cemoktra%2Fgin-tonic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cemoktra%2Fgin-tonic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cemoktra%2Fgin-tonic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cemoktra%2Fgin-tonic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cemoktra","download_url":"https://codeload.github.com/cemoktra/gin-tonic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837286,"owners_count":21169374,"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":["grpc","protobuf","tonic"],"created_at":"2024-11-01T02:09:46.221Z","updated_at":"2025-04-14T07:12:00.766Z","avatar_url":"https://github.com/cemoktra.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"![crates.io](https://img.shields.io/crates/v/gin-tonic.svg)\n\n# gin-tonic\n\n`gin-tonic` offers:\n\n- a protobuf de-/serialization (like [`prost`](http://docs.rs/prost))\n- a replacement for [`prost-build`](http://docs.rs/prost-build))\n- a [`tonic`](http://docs.rs/tonic) codec implementation\n- a wrapper for [`tonic-build`](http://docs.rs/tonic-build) adding some extra extra features\n\nWhile all this can be achieved using the mentioned crates; `gin-tonic` also offers traits for\nconverting any Rust type into a protobuf wire type. You are asking why?\n\nIf you want to pass a UUID via protobuf you likely end up doing:\n\n```protobuf\nmessage Foo {\n  string my_uuid = 1;\n}\n```\n\nUsing [`prost-build`](http://docs.rs/prost-build) and [`tonic-build`](http://docs.rs/tonic-build) this will\ngenerate the following Rust struct:\n\n```rust\nstruct Foo {\n    my_uuid: String,\n}\n```\n\nAs you notice the Rust type here is `String`, but in your actual code you want to use an actual\n[`uuid::Uuid`](docs.rs/uuid). Now you have to do a fallible conversion into your code.\n\n`gin-tonic` solves this by adding options to the protobuf file:\n\n```protobuf\nimport \"gin/proto/gin.proto\";\n\nmessage Foo {\n  string my_uuid = 1 [(gin_tonic.v1.rust_type) = \"uuid::Uuid\"];\n}\n```\n\nUsing the `gin-tonic` code generator this generates the following Rust code:\n\n```rust\nstruct Foo {\n    my_uuid: uuid::Uuid,\n}\n```\n\nFor the UUID case `gin-tonic` offers two features:\n\n- `uuid_string` =\u003e proto transport is `string`, parsing error is handled within wire type conversion\n- `uuid_bytes` =\u003e proto transport is `bytes`, this does not require additional error handling\n\nYou can add you own types by implementing the `PbType` trait for your type.\n\n\n## Benchmarks\ngin tonic:\n```\ndecode                  time:   [699.72 ns 700.71 ns 701.81 ns]\nencode                  time:   [451.35 ns 453.22 ns 455.56 ns]\n```\n\nprost:\n```\ndecode                  time:   [778.30 ns 782.24 ns 788.19 ns]\nencode                  time:   [622.77 ns 623.87 ns 625.02 ns]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcemoktra%2Fgin-tonic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcemoktra%2Fgin-tonic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcemoktra%2Fgin-tonic/lists"}