This commit adjusts the code generation for the internal structs in the implementation of Service<http::Request<HyperBody>> for *Server<T> in order to annotate internal structs whose names are derived from gRPC method names with `[allow(non_camel_case_types)]`. This supresses compiler warnings about type names when compiling generated code. The struct names are not exposed externally, so this has no impact on types seen by library consumers. Fixes #295.
tonic-build
Compiles proto files via prost and generates service stubs and proto definitiones for use with tonic.
Features
- rustfmt: This feature enables the use of rustfmt to format the output code this makes the code readable and the error messages nice. This requires that rustfmt is installed. This is enabled by default.
Required dependencies
[dependencies]
tonic = <tonic-version>
prost = <prost-version>
[build-dependencies]
tonic-build = <tonic-version>
Examples
Simple
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::prost::compile_protos("proto/service.proto")?;
Ok(())
}
Configuration
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::prost::configure()
.build_server(false)
.compile(
&["proto/helloworld/helloworld.proto"],
&["proto/helloworld"],
)?;
Ok(())
}