You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow the transport functionality of tonic-build to be attribute-based rather than completely included/omitted.
Crates
tonic-build
Motivation
I am using tonic in a Rust crate that targets both regular environments and wasm32. The transport feature needs to be disabled for wasm32, and so I end up having to generate 2 completely different sets of files (i.e. run through the builder once with the feature enabled and a "with-transport" dir, and then a second time with "no-transport" dir.)
It works, but, not without some friction.
Alternatively, parsing the output with a regex replacement and feature-gating, which is smoother for consumers but a bit scary to ensure it's doing the right thing consistently.
Proposal
I'm not familiar with the internals of tonic-build to know if it's possible, but the idea would be to use the client_attribute and server_attribute functionality, or something like, it to generate the transport stuff with the cfg rules there, such that consumer crates can use the same files regardless, i.e. move the determination of "transport" down to the consumer level.
This could, of course, merely be an extension on top of the current functionality (i.e. not having the transport feature won't emit it at all, this would only be an additional configuration on top of the current functionality, and should be fully backwards-compatible)
The text was updated successfully, but these errors were encountered:
Feature Request
Allow the
transport
functionality oftonic-build
to be attribute-based rather than completely included/omitted.Crates
tonic-build
Motivation
I am using tonic in a Rust crate that targets both regular environments and wasm32. The transport feature needs to be disabled for wasm32, and so I end up having to generate 2 completely different sets of files (i.e. run through the builder once with the feature enabled and a "with-transport" dir, and then a second time with "no-transport" dir.)
It works, but, not without some friction.
Alternatively, parsing the output with a regex replacement and feature-gating, which is smoother for consumers but a bit scary to ensure it's doing the right thing consistently.
Proposal
I'm not familiar with the internals of tonic-build to know if it's possible, but the idea would be to use the
client_attribute
andserver_attribute
functionality, or something like, it to generate the transport stuff with thecfg
rules there, such that consumer crates can use the same files regardless, i.e. move the determination of "transport" down to the consumer level.This could, of course, merely be an extension on top of the current functionality (i.e. not having the transport feature won't emit it at all, this would only be an additional configuration on top of the current functionality, and should be fully backwards-compatible)
The text was updated successfully, but these errors were encountered: