{"id":13671660,"url":"https://github.com/andrewhickman/prost-reflect","last_synced_at":"2025-10-07T09:59:18.514Z","repository":{"id":38384168,"uuid":"439728561","full_name":"andrewhickman/prost-reflect","owner":"andrewhickman","description":"A protobuf library extending prost with reflection support and dynamic messages.","archived":false,"fork":false,"pushed_at":"2025-09-13T14:54:52.000Z","size":1165,"stargazers_count":127,"open_issues_count":17,"forks_count":30,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-13T16:36:48.397Z","etag":null,"topics":["protobuf","rust","serialization"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/prost-reflect","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/andrewhickman.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-12-18T22:36:33.000Z","updated_at":"2025-09-13T14:53:58.000Z","dependencies_parsed_at":"2023-02-08T21:15:44.678Z","dependency_job_id":"a8c7c9c3-e26b-4ab2-a3a0-f75206dc82eb","html_url":"https://github.com/andrewhickman/prost-reflect","commit_stats":{"total_commits":387,"total_committers":7,"mean_commits":"55.285714285714285","dds":"0.025839793281653756","last_synced_commit":"5777b551e8728230b8c5ddc8cde4dead122f94bf"},"previous_names":[],"tags_count":57,"template":false,"template_full_name":null,"purl":"pkg:github/andrewhickman/prost-reflect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewhickman%2Fprost-reflect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewhickman%2Fprost-reflect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewhickman%2Fprost-reflect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewhickman%2Fprost-reflect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrewhickman","download_url":"https://codeload.github.com/andrewhickman/prost-reflect/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewhickman%2Fprost-reflect/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278755161,"owners_count":26040034,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["protobuf","rust","serialization"],"created_at":"2024-08-02T09:01:15.714Z","updated_at":"2025-10-07T09:59:18.503Z","avatar_url":"https://github.com/andrewhickman.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"[![crates.io](https://img.shields.io/crates/v/prost-reflect.svg)](https://crates.io/crates/prost-reflect/)\n[![docs.rs](https://docs.rs/prost-reflect/badge.svg)](https://docs.rs/prost-reflect/)\n[![deps.rs](https://deps.rs/crate/prost-reflect/latest/status.svg)](https://deps.rs/crate/prost-reflect)\n![MSRV](https://img.shields.io/badge/rustc-1.74+-blue.svg)\n[![Continuous integration](https://github.com/andrewhickman/prost-reflect/actions/workflows/ci.yml/badge.svg)](https://github.com/andrewhickman/prost-reflect/actions/workflows/ci.yml)\n[![codecov.io](https://codecov.io/gh/andrewhickman/prost-reflect/branch/main/graph/badge.svg?token=E2OITYXO7M)](https://codecov.io/gh/andrewhickman/prost-reflect)\n![Apache 2.0 OR MIT licensed](https://img.shields.io/badge/license-Apache2.0%2FMIT-blue.svg)\n\n# prost-reflect\n\nA protobuf library extending [`prost`](https://crates.io/crates/prost) with reflection support and dynamic messages.\n\n## Usage\n\nThis crate provides support for dynamic protobuf messages. These are useful when the\nprotobuf type definition is not known ahead of time.\n\nThe main entry points into the API of this crate are:\n\n- [`DescriptorPool`] wraps a [`FileDescriptorSet`][prost_types::FileDescriptorSet] output by\n  the protobuf compiler to provide an API for inspecting type definitions.\n- [`DynamicMessage`] provides encoding, decoding and reflection of an arbitrary protobuf\n  message definition described by a [`MessageDescriptor`].\n\n### Example - decoding\n\n`DynamicMessage` does not implement [`Default`] since it needs a message descriptor to\nfunction. To decode a protobuf byte stream into an instance of this type, use [`DynamicMessage::decode`]\nto create a default value for the `MessageDescriptor` instance and merge into it:\n\n```rust\nuse prost::Message;\nuse prost_types::FileDescriptorSet;\nuse prost_reflect::{DynamicMessage, DescriptorPool, Value};\n\nlet pool = DescriptorPool::decode(include_bytes!(\"file_descriptor_set.bin\").as_ref()).unwrap();\nlet message_descriptor = pool.get_message_by_name(\"package.MyMessage\").unwrap();\n\nlet dynamic_message = DynamicMessage::decode(message_descriptor, b\"\\x08\\x96\\x01\".as_ref()).unwrap();\n\nassert_eq!(dynamic_message.get_field_by_name(\"foo\").unwrap().as_ref(), \u0026Value::I32(150));\n```\n\n### Example - JSON mapping\n\nWhen the `serde` feature is enabled, `DynamicMessage` can be deserialized to and from the\n[canonical JSON mapping](https://developers.google.com/protocol-buffers/docs/proto3#json)\ndefined for protobuf messages.\n\n```rust\nuse prost::Message;\nuse prost_reflect::{DynamicMessage, DescriptorPool, Value};\nuse serde_json::de::Deserializer;\n\nlet pool = DescriptorPool::decode(include_bytes!(\"file_descriptor_set.bin\").as_ref()).unwrap();\nlet message_descriptor = pool.get_message_by_name(\"package.MyMessage\").unwrap();\n\nlet json = r#\"{ \"foo\": 150 }\"#;\nlet mut deserializer = Deserializer::from_str(json);\nlet dynamic_message = DynamicMessage::deserialize(message_descriptor, \u0026mut deserializer).unwrap();\ndeserializer.end().unwrap();\n\nassert_eq!(dynamic_message.get_field_by_name(\"foo\").unwrap().as_ref(), \u0026Value::I32(150));\n```\n\n### Example - implementing `ReflectMessage`\n\nThe [`ReflectMessage`] trait provides a `.descriptor()` method to get type information for a message. It is implemented for `DynamicMessage` and the well-known-types provided by [`prost-types`](https://docs.rs/prost-types/0.10.0/prost_types).\n\nWhen the `derive` feature is enabled, it can be derived for [`Message`][prost::Message] implementations. The\nderive macro takes the following parameters:\n\n| Name            | Value |\n|-----------------|-------|\n| descriptor_pool | An expression that resolves to a [`DescriptorPool`] containing the message type. The descriptor should be cached to avoid re-building it. Either this or `file_descriptor_pool_bytes` must be set |\n| file_descriptor_pool_bytes | An expression that resolves to an implementation of `Buf` containing an encoded file descriptor set. This will be automatically added to the global descriptor pool the first time `ReflectMessage::descriptor()` is called. |\n| message_name    | The full name of the message, used to look it up within [`DescriptorPool`]. |\n\n```rust\nuse prost::Message;\nuse prost_reflect::{DescriptorPool, ReflectMessage};\nuse once_cell::sync::Lazy;\n\nstatic DESCRIPTOR_POOL: Lazy\u003cDescriptorPool\u003e\n    = Lazy::new(|| DescriptorPool::decode(include_bytes!(\"file_descriptor_set.bin\").as_ref()).unwrap());\n\n#[derive(Message, ReflectMessage)]\n#[prost_reflect(descriptor_pool = \"DESCRIPTOR_POOL\", message_name = \"package.MyMessage\")]\npub struct MyMessage {}\n\nlet message = MyMessage {};\nassert_eq!(message.descriptor().full_name(), \"package.MyMessage\");\n```\n\nIf you are using `prost-build`, the [`prost-reflect-build`](https://crates.io/crates/prost-reflect-build) crate provides helpers to generate `ReflectMessage` implementations:\n\n```rust,no_run\nprost_reflect_build::Builder::new()\n    .compile_protos(\u0026[\"src/package.proto\"], \u0026[\"src\"])\n    .unwrap();\n```\n\n## Minimum Supported Rust Version\n\nRust **1.74** or higher.\n\nThe minimum supported Rust version may be changed in the future, but it will be\ndone with a minor version bump.\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0\n   ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license\n   ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n\n[`DescriptorPool`]: https://docs.rs/prost-reflect/latest/prost_reflect/struct.DescriptorPool.html\n[`DynamicMessage`]: https://docs.rs/prost-reflect/latest/prost_reflect/struct.DynamicMessage.html\n[`MessageDescriptor`]: https://docs.rs/prost-reflect/latest/prost_reflect/struct.MessageDescriptor.html\n[`MessageDescriptor`]: https://docs.rs/prost-reflect/latest/prost_reflect/struct.MessageDescriptor.html\n[`DynamicMessage::decode`]: https://docs.rs/prost-reflect/latest/prost_reflect/struct.DynamicMessage.html#method.decode\n[`ReflectMessage`]: https://docs.rs/prost-reflect/latest/prost_reflect/trait.ReflectMessage.html\n\n[`Default`]: https://doc.rust-lang.org/stable/core/default/trait.Default.html\n[prost::Message]: https://docs.rs/prost/latest/prost/trait.Message.html\n[prost_types::FileDescriptorSet]: https://docs.rs/prost-types/latest/prost_types/struct.FileDescriptorSet.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewhickman%2Fprost-reflect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewhickman%2Fprost-reflect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewhickman%2Fprost-reflect/lists"}