Skip to content

Conversation

@swallez
Copy link
Contributor

@swallez swallez commented May 17, 2024

Extracts the file descriptor loading part from prost_build::compile_protos() to a new prost_build::load_fds() function.

This allows inspection or even modification of descriptors before calling prost_build::compile_fds. Possible use cases include generating additional files from the descriptors, or set computed Config attributes by introspecting what is actually present in the .proto files before generating the code.

Copy link
Contributor

@caspermeijn caspermeijn left a comment

Choose a reason for hiding this comment

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

I would like to see a test that actually uses this. Maybe you could edit an existing test to do some introspection?

/// let mut config = Config::new();
/// let file_descriptor_set = config.load_fds(&["src/frontend.proto", "src/backend.proto"], &["src"])?;
///
/// // Inspect file_descriptor_set and tweak config
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you change this to a concrete example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in cbf0813.

@swallez
Copy link
Contributor Author

swallez commented May 31, 2024

@caspermeijn Thanks for the review. I've added a usage example in the test_generate_message_attributes test and to the docs.

Copy link
Contributor

@caspermeijn caspermeijn left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution

@swallez
Copy link
Contributor Author

swallez commented Jul 19, 2024

Thanks @caspermeijn! What is the next step for this PR to be merged?

@caspermeijn caspermeijn added this pull request to the merge queue Jul 19, 2024
@caspermeijn
Copy link
Contributor

Thanks @caspermeijn! What is the next step for this PR to be merged?

There you go

Merged via the queue into tokio-rs:master with commit 6009233 Jul 19, 2024
@swallez swallez deleted the read-fds branch July 19, 2024 20:08
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