[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-5792":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":28,"readmeContent":29,"aiSummary":30,"trendingCount":16,"starSnapshotCount":16,"syncStatus":31,"lastSyncTime":32,"discoverSource":33},5792,"prost","tokio-rs\u002Fprost","tokio-rs","PROST! a Protocol Buffers implementation for the Rust Language","",null,"Rust",4712,622,31,188,0,1,6,25,5,30.38,"Apache License 2.0",false,"master",[26,27],"protobuf","rust","2026-06-12 02:01:14","[![maintenance-status: passively-maintained](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fmaintenance--status-passively--maintained-forestgreen)](https:\u002F\u002Fgist.github.com\u002Frusty-snake\u002F574a91f1df9f97ec77ca308d6d731e29)\n[![continuous integration](https:\u002F\u002Fgithub.com\u002Ftokio-rs\u002Fprost\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg?branch=master)](https:\u002F\u002Fgithub.com\u002Ftokio-rs\u002Fprost\u002Factions\u002Fworkflows\u002Fci.yml?query=branch%3Amaster)\n[![Documentation](https:\u002F\u002Fdocs.rs\u002Fprost\u002Fbadge.svg)](https:\u002F\u002Fdocs.rs\u002Fprost\u002F)\n[![Crate](https:\u002F\u002Fimg.shields.io\u002Fcrates\u002Fv\u002Fprost.svg)](https:\u002F\u002Fcrates.io\u002Fcrates\u002Fprost)\n[![Dependency Status](https:\u002F\u002Fdeps.rs\u002Frepo\u002Fgithub\u002Ftokio-rs\u002Fprost\u002Fstatus.svg)](https:\u002F\u002Fdeps.rs\u002Frepo\u002Fgithub\u002Ftokio-rs\u002Fprost)\n[![Discord](https:\u002F\u002Fimg.shields.io\u002Fdiscord\u002F500028886025895936)](https:\u002F\u002Fdiscord.gg\u002Ftokio)\n\n# *PROST!*\n\n`prost` is a [Protocol Buffers](https:\u002F\u002Fprotobuf.dev\u002F)\nimplementation for the [Rust Language](https:\u002F\u002Fwww.rust-lang.org\u002F). `prost`\ngenerates simple, idiomatic Rust code from `proto2` and `proto3` files.\n\nCompared to other Protocol Buffers implementations, `prost`\n\n* Generates simple, idiomatic, and readable Rust types by taking advantage of\n  Rust `derive` attributes.\n* Retains comments from `.proto` files in generated Rust code.\n* Allows existing Rust types (not generated from a `.proto`) to be serialized\n  and deserialized by adding attributes.\n* Uses the [`bytes::{Buf, BufMut}`](https:\u002F\u002Fgithub.com\u002Ftokio-rs\u002Fbytes)\n  abstractions for serialization instead of `std::io::{Read, Write}`.\n* Respects the Protobuf `package` specifier when organizing generated code\n  into Rust modules.\n* Preserves unknown enum values during deserialization.\n* Does not include support for runtime reflection or message descriptors.\n\n## Using `prost` in a Cargo Project\n\nFirst, add `prost` and its public dependencies to your `Cargo.toml`:\n\n```ignore\n[dependencies]\nprost = \"0.14\"\n# Only necessary if using Protobuf well-known types:\nprost-types = \"0.14\"\n```\n\nThe recommended way to add `.proto` compilation to a Cargo project is to use the\n`prost-build` library. See the [`prost-build` documentation][prost-build] for\nmore details and examples.\n\nSee the [snazzy repository][snazzy] for a simple start-to-finish example.\n\n[prost-build]: https:\u002F\u002Fdocs.rs\u002Fprost-build\u002Flatest\u002Fprost_build\u002F\n[snazzy]: https:\u002F\u002Fgithub.com\u002Fdanburkert\u002Fsnazzy\n\n### MSRV\n\n`prost` follows the `tokio-rs` project's MSRV model and supports 1.82. For more\ninformation on the tokio msrv policy you can check it out [here][tokio msrv]\n\n[tokio msrv]: https:\u002F\u002Fgithub.com\u002Ftokio-rs\u002Ftokio\u002F#supported-rust-versions\n\n## Generated Code\n\n`prost` generates Rust code from source `.proto` files using the `proto2` or\n`proto3` syntax. `prost`'s goal is to make the generated code as simple as\npossible.\n\n### `protoc`\n\nWith `prost-build` v0.11 release, `protoc` will be required to invoke\n`compile_protos` (unless `skip_protoc` is enabled). Prost will no longer provide\nbundled `protoc` or attempt to compile `protoc` for users. For install\ninstructions for `protoc`, please check out the [protobuf install] instructions.\n\n[protobuf install]: https:\u002F\u002Fgithub.com\u002Fprotocolbuffers\u002Fprotobuf#protobuf-compiler-installation\n\n\n### Packages\n\nProst can now generate code for `.proto` files that don't have a package spec.\n`prost` will translate the Protobuf package into\na Rust module. For example, given the `package` specifier:\n\n[package]: https:\u002F\u002Fprotobuf.dev\u002Fprogramming-guides\u002Fproto3\u002F#packages\n\n```protobuf,ignore\npackage foo.bar;\n```\n\nAll Rust types generated from the file will be in the `foo::bar` module.\n\n### Messages\n\nGiven a simple message declaration:\n\n```protobuf,ignore\n\u002F\u002F Sample message.\nmessage Foo {\n}\n```\n\n`prost` will generate the following Rust struct:\n\n```rust,ignore\n\u002F\u002F\u002F Sample message.\n#[derive(Clone, Debug, PartialEq, Message)]\npub struct Foo {\n}\n```\n\n### Fields\n\nFields in Protobuf messages are translated into Rust as public struct fields of the\ncorresponding type.\n\n#### Scalar Values\n\nScalar value types are converted as follows:\n\n| Protobuf Type | Rust Type |\n| --- | --- |\n| `double` | `f64` |\n| `float` | `f32` |\n| `int32` | `i32` |\n| `int64` | `i64` |\n| `uint32` | `u32` |\n| `uint64` | `u64` |\n| `sint32` | `i32` |\n| `sint64` | `i64` |\n| `fixed32` | `u32` |\n| `fixed64` | `u64` |\n| `sfixed32` | `i32` |\n| `sfixed64` | `i64` |\n| `bool` | `bool` |\n| `string` | `String` |\n| `bytes` | `Vec\u003Cu8>` |\n\n#### Enumerations\n\nAll `.proto` enumeration types convert to the Rust `i32` type. Additionally,\neach enumeration type gets a corresponding Rust `enum` type. For example, this\n`proto` enum:\n\n```protobuf,ignore\nenum PhoneType {\n  MOBILE = 0;\n  HOME = 1;\n  WORK = 2;\n}\n```\n\ngets this corresponding Rust enum [^1]:\n\n```rust,ignore\npub enum PhoneType {\n    Mobile = 0,\n    Home = 1,\n    Work = 2,\n}\n```\n\n[^1]: Annotations have been elided for clarity. See below for a full example.\n\nYou can convert a `PhoneType` value to an `i32` by doing:\n\n```rust,ignore\nPhoneType::Mobile as i32\n```\n\nThe `#[derive(::prost::Enumeration)]` annotation added to the generated\n`PhoneType` adds these associated functions to the type:\n\n```rust,ignore\nimpl PhoneType {\n    pub const fn is_valid(value: i32) -> bool { ... }\n    #[deprecated]\n    pub fn from_i32(value: i32) -> Option\u003CPhoneType> { ... }\n}\n```\n\nIt also adds an `impl TryFrom\u003Ci32> for PhoneType`, so you can convert an `i32` to its corresponding `PhoneType` value by doing,\nfor example:\n\n```rust,ignore\nlet phone_type = 2i32;\n\nmatch PhoneType::try_from(phone_type) {\n    Ok(PhoneType::Mobile) => ...,\n    Ok(PhoneType::Home) => ...,\n    Ok(PhoneType::Work) => ...,\n    Err(_) => ...,\n}\n```\n\nAdditionally, wherever a `proto` enum is used as a field in a `Message`, the\nmessage will have 'accessor' methods to get\u002Fset the value of the field as the\nRust enum type. For instance, this proto `PhoneNumber` message that has a field\nnamed `type` of type `PhoneType`:\n\n```protobuf,ignore\nmessage PhoneNumber {\n  string number = 1;\n  PhoneType type = 2;\n}\n```\n\nwill become the following Rust type [^2] with methods `type` and `set_type`:\n\n```rust,ignore\npub struct PhoneNumber {\n    pub number: String,\n    pub r#type: i32, \u002F\u002F the `r#` is needed because `type` is a Rust keyword\n}\n\nimpl PhoneNumber {\n    pub fn r#type(&self) -> PhoneType { ... }\n    pub fn set_type(&mut self, value: PhoneType) { ... }\n}\n```\n\nNote that the getter methods will return the Rust enum's default value if the\nfield has an invalid `i32` value.\n\nThe `enum` type isn't used directly as a field, because the Protobuf spec\nmandates that enumerations values are 'open', and decoding unrecognized\nenumeration values must be possible.\n\n[^2]: Annotations have been elided for clarity. See below for a full example.\n\n#### Field Modifiers\n\nProtobuf scalar value and enumeration message fields can have a modifier\ndepending on the Protobuf version. Modifiers change the corresponding type of\nthe Rust field:\n\n| `.proto` Version | Modifier | Rust Type |\n| --- | --- | --- |\n| `proto2` | `optional` | `Option\u003CT>` |\n| `proto2` | `required` | `T` |\n| `proto3` | default | `T` for scalar types, `Option\u003CT>` otherwise |\n| `proto3` | `optional` | `Option\u003CT>` |\n| `proto2`\u002F`proto3` | `repeated` | `Vec\u003CT>` |\n\nNote that in `proto3` the default representation for all user-defined message\ntypes is `Option\u003CT>`, and for scalar types just `T` (during decoding, a missing\nvalue is populated by `T::default()`). If you need a witness of the presence of\na scalar type `T`, use the `optional` modifier to enforce an `Option\u003CT>`\nrepresentation in the generated Rust struct.\n\n#### Map Fields\n\nMap fields are converted to a Rust `HashMap` with key and value type converted\nfrom the Protobuf key and value types.\n\n#### Message Fields\n\nMessage fields are converted to the corresponding struct type. The table of\nfield modifiers above applies to message fields, except that `proto3` message\nfields without a modifier (the default) will be wrapped in an `Option`.\nTypically message fields are unboxed. `prost` will automatically box a message\nfield if the field type and the parent type are recursively nested in order to\navoid an infinite sized struct.\n\n#### Oneof Fields\n\nOneof fields convert to a Rust enum. Protobuf `oneof`s types are not named, so\n`prost` uses the name of the `oneof` field for the resulting Rust enum, and\ndefines the enum in a module under the struct. For example, a `proto3` message\nsuch as:\n\n```protobuf,ignore\nmessage Foo {\n  oneof widget {\n    int32 quux = 1;\n    string bar = 2;\n  }\n}\n```\n\ngenerates the following Rust[^3]:\n\n```rust,ignore\npub struct Foo {\n    pub widget: Option\u003Cfoo::Widget>,\n}\npub mod foo {\n    pub enum Widget {\n        Quux(i32),\n        Bar(String),\n    }\n}\n```\n\n`oneof` fields are always wrapped in an `Option`.\n\n[^3]: Annotations have been elided for clarity. See below for a full example.\n\n### Services\n\n`prost-build` allows a custom code-generator to be used for processing `service`\ndefinitions. This can be used to output Rust traits according to an\napplication's specific needs.\n\n### Generated Code Example\n\nExample `.proto` file:\n\n```protobuf,ignore\nsyntax = \"proto3\";\npackage tutorial;\n\nmessage Person {\n  string name = 1;\n  int32 id = 2;  \u002F\u002F Unique ID number for this person.\n  string email = 3;\n\n  enum PhoneType {\n    MOBILE = 0;\n    HOME = 1;\n    WORK = 2;\n  }\n\n  message PhoneNumber {\n    string number = 1;\n    PhoneType type = 2;\n  }\n\n  repeated PhoneNumber phones = 4;\n}\n\n\u002F\u002F Our address book file is just one of these.\nmessage AddressBook {\n  repeated Person people = 1;\n}\n```\n\nand the generated Rust code (`tutorial.rs`):\n\n```rust,ignore\n#[derive(Clone, PartialEq, ::prost::Message)]\npub struct Person {\n    #[prost(string, tag=\"1\")]\n    pub name: ::prost::alloc::string::String,\n    \u002F\u002F\u002F Unique ID number for this person.\n    #[prost(int32, tag=\"2\")]\n    pub id: i32,\n    #[prost(string, tag=\"3\")]\n    pub email: ::prost::alloc::string::String,\n    #[prost(message, repeated, tag=\"4\")]\n    pub phones: ::prost::alloc::vec::Vec\u003Cperson::PhoneNumber>,\n}\n\u002F\u002F\u002F Nested message and enum types in `Person`.\npub mod person {\n    #[derive(Clone, PartialEq, ::prost::Message)]\n    pub struct PhoneNumber {\n        #[prost(string, tag=\"1\")]\n        pub number: ::prost::alloc::string::String,\n        #[prost(enumeration=\"PhoneType\", tag=\"2\")]\n        pub r#type: i32,\n    }\n    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]\n    #[repr(i32)]\n    pub enum PhoneType {\n        Mobile = 0,\n        Home = 1,\n        Work = 2,\n    }\n}\n\u002F\u002F\u002F Our address book file is just one of these.\n#[derive(Clone, PartialEq, ::prost::Message)]\npub struct AddressBook {\n    #[prost(message, repeated, tag=\"1\")]\n    pub people: ::prost::alloc::vec::Vec\u003CPerson>,\n}\n```\n\n## Accessing the `protoc` `FileDescriptorSet`\n\nThe `prost_build::Config::file_descriptor_set_path` option can be used to emit a file descriptor set\nduring the build & code generation step. When used in conjunction with the `std::include_bytes`\nmacro and the `prost_types::FileDescriptorSet` type, applications and libraries using Prost can\nimplement introspection capabilities requiring details from the original `.proto` files.\n\n## Using `prost` in a `no_std` Crate\n\n`prost` is compatible with `no_std` crates. To enable `no_std` support, disable\nthe `std` features in `prost` and `prost-types`:\n\n```ignore\n[dependencies]\nprost = { version = \"0.14.3\", default-features = false, features = [\"derive\"] }\n# Only necessary if using Protobuf well-known types:\nprost-types = { version = \"0.14.3\", default-features = false }\n```\n\nAdditionally, configure `prost-build` to output `BTreeMap`s instead of `HashMap`s\nfor all Protobuf `map` fields in your `build.rs`:\n\n```rust,ignore\nlet mut config = prost_build::Config::new();\nconfig.btree_map(&[\".\"]);\n```\n\nWhen using edition 2015, it may be necessary to add an `extern crate core;`\ndirective to the crate which includes `prost`-generated code.\n\n## Serializing Existing Types\n\n`prost` uses a custom derive macro to handle encoding and decoding types, which\nmeans that if your existing Rust type is compatible with Protobuf types, you can\nserialize and deserialize it by adding the appropriate derive and field\nannotations.\n\nCurrently the best documentation on adding annotations is to look at the\ngenerated code examples above.\n\n### Tag Inference for Existing Types\n\nProst automatically infers tags for the struct.\n\nFields are tagged sequentially in the order they\nare specified, starting with `1`.\n\nYou may skip tags which have been reserved, or where there are gaps between\nsequentially occurring tag values by specifying the tag number to skip to with\nthe `tag` attribute on the first field after the gap. The following fields will\nbe tagged sequentially starting from the next number.\n\n```rust,ignore\nuse prost;\nuse prost::{Enumeration, Message};\n\n#[derive(Clone, PartialEq, Message)]\nstruct Person {\n    #[prost(string, tag = \"1\")]\n    pub id: String, \u002F\u002F tag=1\n    \u002F\u002F NOTE: Old \"name\" field has been removed\n    \u002F\u002F pub name: String, \u002F\u002F tag=2 (Removed)\n    #[prost(string, tag = \"6\")]\n    pub given_name: String, \u002F\u002F tag=6\n    #[prost(string)]\n    pub family_name: String, \u002F\u002F tag=7\n    #[prost(string)]\n    pub formatted_name: String, \u002F\u002F tag=8\n    #[prost(uint32, tag = \"3\")]\n    pub age: u32, \u002F\u002F tag=3\n    #[prost(uint32)]\n    pub height: u32, \u002F\u002F tag=4\n    #[prost(enumeration = \"Gender\")]\n    pub gender: i32, \u002F\u002F tag=5\n    \u002F\u002F NOTE: Skip to less commonly occurring fields\n    #[prost(string, tag = \"16\")]\n    pub name_prefix: String, \u002F\u002F tag=16  (eg. mr\u002Fmrs\u002Fms)\n    #[prost(string)]\n    pub name_suffix: String, \u002F\u002F tag=17  (eg. jr\u002Fesq)\n    #[prost(string)]\n    pub maiden_name: String, \u002F\u002F tag=18\n}\n\n#[derive(Clone, Copy, Debug, PartialEq, Eq, Enumeration)]\npub enum Gender {\n    Unknown = 0,\n    Female = 1,\n    Male = 2,\n}\n```\n\n## Nix\n\nThe prost project supports development using Nix flakes. Once you have Nix and flakes enabled, you can simply run:\n\n```bash\nnix develop\n```\n\nThis will drop you into a shell with all dependencies configured to build the entire project.\n\nIf you want to use the minimum supported Rust version ([see MSRV](#msrv)) as required by policy, run:\n\n```bash\nnix develop .#rust_minimum_version\n```\n\nThis ensures compatibility testing and development with the oldest supported toolchain version.\n\n## Feature Flags\n- `std`: Enable integration with standard library. Disable this feature for `no_std` support. This feature is enabled by default.\n- `derive`: Enable integration with `prost-derive`. Disable this feature to reduce compile times. This feature is enabled by default.\n- `prost-derive`: Deprecated. Alias for `derive` feature.\n- `no-recursion-limit`: Disable the recursion limit. The recursion limit is 100 and cannot be customized. \n\n## Contributing\n\nThe current maintainer is not contributing new features and doesn't have the time to review new features. Bug fixes and small improvements are welcome. Feel free to contribute small and easily reviewable PRs. \n\nBug fixes are still important, and security fixes will be released as soon as possible. Contact the `#prost` channel in [Tokio discord](https:\u002F\u002Fdiscord.gg\u002Ftokio) if you feel a bug or security fix is not getting enough attention.\n\nThe maintainer expects the official `protobuf` project to release their rust library soon and expects it to be as fully featured as the C++ library. See their [source code](https:\u002F\u002Fgithub.com\u002Fprotocolbuffers\u002Fprotobuf\u002Ftree\u002Fmain\u002Frust) and [crate](https:\u002F\u002Fcrates.io\u002Fcrates\u002Fprotobuf\u002F4.33.1-release) for more information.\n\n## FAQ\n\n1. **Could `prost` be implemented as a serializer for [Serde](https:\u002F\u002Fserde.rs\u002F)?**\n\n   Probably not, however I would like to hear from a Serde expert on the matter.\n   There are two complications with trying to serialize Protobuf messages with\n   Serde:\n\n   - Protobuf fields require a numbered tag, and currently there appears to be no\n     mechanism suitable for this in `serde`.\n   - The mapping of Protobuf type to Rust type is not 1-to-1. As a result,\n     trait-based approaches to dispatching don't work very well. Example: six\n     different Protobuf field types correspond to a Rust `Vec\u003Ci32>`: `repeated\n     int32`, `repeated sint32`, `repeated sfixed32`, and their packed\n     counterparts.\n\n   But it is possible to place `serde` derive tags onto the generated types, so\n   the same structure can support both `prost` and `Serde`.\n\n2. **I get errors when trying to run `cargo test` on MacOS**\n\n   If the errors are about missing `autoreconf` or similar, you can probably fix\n   them by running\n\n   ```ignore\n   brew install automake\n   brew install libtool\n   ```\n\n3. **Why are most fields are wrapped in an `Option`?**\n\n   In the `protobuf` wire protocol all fields are optional. The design of `prost` choose to expose\n   this to the user of the types. `prost` leans toward correctness and safety, aligned with Rust’s \n   philosophy — even at the cost of verbosity.\n\n## License\n\n`prost` is distributed under the terms of the Apache License (Version 2.0).\n\nSee [LICENSE](https:\u002F\u002Fgithub.com\u002Ftokio-rs\u002Fprost\u002Fblob\u002Fmaster\u002FLICENSE) for details.\n\nCopyright 2022 Dan Burkert & Tokio Contributors\n","`prost` 是一个为 Rust 语言实现的 Protocol Buffers 库，支持 `proto2` 和 `proto3` 文件的解析与生成。其核心功能包括利用 Rust 的 `derive` 属性生成简洁、易读且符合 Rust 风格的类型代码，保留 `.proto` 文件中的注释，并允许非自动生成的 Rust 类型通过添加属性来实现序列化和反序列化。此外，`prost` 使用 `bytes::{Buf, BufMut}` 抽象进行序列化操作而非标准库的 I\u002FO 操作，同时尊重 Protobuf 的 `package` 指定以组织生成的 Rust 模块结构。此项目适用于需要高效数据交换格式及跨语言通信能力的 Rust 项目中，特别是在微服务架构或分布式系统开发场景下。",2,"2026-06-11 03:05:03","top_language"]