{"id":28486131,"url":"https://github.com/containerd/ttrpc-rust","last_synced_at":"2025-07-02T12:32:17.719Z","repository":{"id":38108603,"uuid":"202681056","full_name":"containerd/ttrpc-rust","owner":"containerd","description":"Rust implementation of ttrpc (GRPC for low-memory environments)","archived":false,"fork":false,"pushed_at":"2025-07-01T09:40:51.000Z","size":729,"stargazers_count":335,"open_issues_count":21,"forks_count":61,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-07-01T10:41:37.890Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/containerd.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,"zenodo":null}},"created_at":"2019-08-16T07:34:02.000Z","updated_at":"2025-07-01T09:40:56.000Z","dependencies_parsed_at":"2023-02-16T12:31:48.888Z","dependency_job_id":"5222387c-a017-4240-82a6-9a511943f35d","html_url":"https://github.com/containerd/ttrpc-rust","commit_stats":{"total_commits":241,"total_committers":24,"mean_commits":"10.041666666666666","dds":0.4273858921161826,"last_synced_commit":"22cd9ca4558ca804398e252adc23fc3290ed547d"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/containerd/ttrpc-rust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/containerd%2Fttrpc-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/containerd%2Fttrpc-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/containerd%2Fttrpc-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/containerd%2Fttrpc-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/containerd","download_url":"https://codeload.github.com/containerd/ttrpc-rust/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/containerd%2Fttrpc-rust/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262950252,"owners_count":23389631,"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-06-08T01:10:20.988Z","updated_at":"2025-07-02T12:32:17.700Z","avatar_url":"https://github.com/containerd.png","language":"Rust","readme":"# ttrpc-rust\n\n_ttrpc-rust is a **non-core** subproject of containerd_\n\n`ttrpc-rust` is the Rust version of [ttrpc](https://github.com/containerd/ttrpc). [ttrpc](https://github.com/containerd/ttrpc) is GRPC for low-memory environments.\n\nThe ttrpc compiler of `ttrpc-rust` `ttrpc_rust_plugin` is modified from gRPC compiler of [gRPC-rs](https://github.com/pingcap/grpc-rs) [grpcio-compiler](https://github.com/pingcap/grpc-rs/tree/master/compiler).\n\n## Usage\n\n### 1. Generate with `protoc` command\nTo generate the sources from proto files:\n\n1. Install protoc from github.com/protocolbuffers/protobuf\n\n2. Install protobuf-codegen\n```\ncargo install --force protobuf-codegen\n```\n\n3. Install ttrpc_rust_plugin from ttrpc-rust/compiler\n```\ncd ttrpc-rust/compiler\ncargo install --force --path .\n```\n\n4. Generate the sources:\n\n```\n$ protoc --rust_out=. --ttrpc_out=. --plugin=protoc-gen-ttrpc=`which ttrpc_rust_plugin` example.proto\n```\n\n\n### 2. Generate programmatically\n\nAPI to generate .rs files to be used e. g. from build.rs.\n\nExample code:\n\n```\nfn main() {\n    protoc_rust_ttrpc::Codegen::new()\n        .out_dir(\"protocols\")\n        .inputs(\u0026[\n            \"protocols/protos/agent.proto\",\n        ])\n        .include(\"protocols/protos\")\n        .rust_protobuf() // also generate protobuf messages, not just services\n        .run()\n        .expect(\"Codegen failed.\");\n}\n```\n\n# async/.await\nttrpc-rust supports async/.await. By using async/.await you can reduce the overhead and resource consumption caused by threads.\n\n## Usage\n### 1. Generate codes in async version\nCurrently we only support generating async codes by using ttrpc-codegen\n\n```\n    ttrpc_codegen::Codegen::new()\n        .out_dir(\"protocols/asynchronous\")\n        .inputs(\u0026protos)\n        .include(\"protocols/protos\")\n        .rust_protobuf()\n        .customize(Customize {\n            gen_mod: true, // Gen mod will add mod.rs in out_dir.It's compatible with protobuf's gen_mod_rs\n            async_all: true, // It's the key option.\n            ..Default::default()\n        })\n        .run()\n        .expect(\"Gen async codes failed.\");\n```\n\nProvide customize option\n- `async_all`: generate async codes for both server and client\n- `async_server`: generate async codes for server\n- `async_client`: generate async codes for client\n- `gen_mod`: generate mod.rs in out_dir\n\n\u003e See more in `example/build.rs`\n\n### 2. Write your implemention in async/.await's way\nPlease follow the guidlines in `example/async-server.rs` and `example/async-client.rs`\n\n# Run Examples\n1. Go to the directory\n\n    ```\n    $ cd ttrpc-rust/example\n    ```\n\n2. Start the server\n\n    ```\n    $ cargo run --example server\n    ```\n    or\n\n    ```\n    $ cargo run --example async-server\n    ```\n\n3. Start a client\n\n    ```\n    $ cargo run --example client\n    ```\n    or\n    ```\n    $ cargo run --example async-client\n    ```\n\n\n# Notes: the version of protobuf\nprotobuf-codegen, ttrpc_rust_plugin and your code should use the same version protobuf.\nYou will get following fail if use the different version protobuf.\n```\n27 | const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_8_0;\n   |                                                 ^^^^^^^^^^^^^ help: a constant with a similar name exists: `VERSION_2_10_1`\n```\nThe reason is that [files generated by protobuf-codegen are compatible only with the same version of runtime](https://github.com/stepancheg/rust-protobuf/commit/2ab4d50c27c4dd7803b64ce1a43e2c134532c7a6)\n\nTo fix this issue:\n1. Rebuild protobuf-codegen with new protobuf:\n```\ncd grpc-rs\ncargo clean\ncargo update\ncargo install --force protobuf-codegen\n```\n2. Rebuild ttrpc_rust_plugin with new protobuf:\n```\ncd ttrpc-rust/compiler\ncargo clean\ncargo update\ncargo install --force --path .\n```\n3. Build your project.\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontainerd%2Fttrpc-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcontainerd%2Fttrpc-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontainerd%2Fttrpc-rust/lists"}