Module tonic_build::manual

source ·
Expand description

This module provides utilities for generating tonic service stubs and clients purely in Rust without the need of proto files. It also enables you to set a custom Codec if you want to use a custom serialization format other than protobuf.

Example

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let greeter_service = tonic_build::manual::Service::builder()
        .name("Greeter")
        .package("helloworld")
        .method(
            tonic_build::manual::Method::builder()
                .name("say_hello")
                .route_name("SayHello")
                // Provide the path to the Request type
                .input_type("crate::HelloRequest")
                // Provide the path to the Response type
                .output_type("super::HelloResponse")
                // Provide the path to the Codec to use
                .codec_path("crate::JsonCodec")
                .build(),
        )
        .build();

    tonic_build::manual::Builder::new().compile(&[greeter_service]);
    Ok(())
}

Structs

Service generator builder.
A service method descriptor.
Method builder.
A service descriptor.
Service builder.