Skip to content

feat: add prost-reflect support - #131

Merged
siennathesane merged 4 commits into
neoeinstein:mainfrom
YangchenYe323:feat/support-prost-reflect
Dec 15, 2025
Merged

feat: add prost-reflect support#131
siennathesane merged 4 commits into
neoeinstein:mainfrom
YangchenYe323:feat/support-prost-reflect

Conversation

@YangchenYe323

@YangchenYe323 YangchenYe323 commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

Hi there, I added support of generating prost_reflect trait implementations to protoc-gen-prost. It is controlled by option prost_reflect, which depends on file_descriptor_set, and the behavior change is:

  1. If set, FileDescriptorSetGenerator will generate all the dependencies in addition to the original proto file, as prost-reflect DescriptorPool requires all the proto files are present in the set.
  2. Configure the prost-build config to add the necessary type attribute and trait derive.

I've tested and it's working with my protobuf project with prost-reflect: 0.16.1

Happy to update the doc and example if this is released

@YangchenYe323
YangchenYe323 marked this pull request as draft December 10, 2025 15:08
@YangchenYe323
YangchenYe323 marked this pull request as ready for review December 10, 2025 17:08
@siennathesane

Copy link
Copy Markdown
Collaborator

I'm open to it, but please add it to the documentation so that it's obvious to other users as well.

@YangchenYe323 YangchenYe323 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@siennathesane Addressed your comment. The cargo fmt CI is fixed. The vet dependency one is still failing, but doesn't seem to be related to this PR

Comment on lines +60 to +64
* `prost_reflect`: When specified together with `file_descriptor_set`, generate
implementations of [prost_reflect::ReflectMessage](https://docs.rs/prost-reflect/latest/prost_reflect/trait.ReflectMessage.html) trait for the generated rust struct. Note that this option
depends on `file_descriptor_set`, and when enabled, the generated `FileDescriptorSet`
*will* include all the dependent protobuf files in addition to the module being generated,
which required for prost_reflect descriptor to work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added documentation here. Let me know if there's other places I need to update

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this is good!

@siennathesane siennathesane left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Comment on lines +60 to +64
* `prost_reflect`: When specified together with `file_descriptor_set`, generate
implementations of [prost_reflect::ReflectMessage](https://docs.rs/prost-reflect/latest/prost_reflect/trait.ReflectMessage.html) trait for the generated rust struct. Note that this option
depends on `file_descriptor_set`, and when enabled, the generated `FileDescriptorSet`
*will* include all the dependent protobuf files in addition to the module being generated,
which required for prost_reflect descriptor to work.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this is good!

@siennathesane
siennathesane merged commit 66e368a into neoeinstein:main Dec 15, 2025
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants