Struct tonic_build::manual::MethodBuilder
source · pub struct MethodBuilder { /* private fields */ }
Expand description
Method builder.
This builder can be used to manually define gRPC method, which can be added to a gRPC service, in rust code without the use of a .proto file.
§Example
let say_hello_method = Method::builder()
.name("say_hello")
.route_name("SayHello")
// Provide the path to the Request type
.input_type("crate::common::HelloRequest")
// Provide the path to the Response type
.output_type("crate::common::HelloResponse")
// Provide the path to the Codec to use
.codec_path("crate::common::JsonCodec")
.build();
Implementations§
source§impl MethodBuilder
impl MethodBuilder
sourcepub fn name(self, name: impl AsRef<str>) -> Self
pub fn name(self, name: impl AsRef<str>) -> Self
Set the name for this Method.
This value will be used for generating the client functions for calling this Method.
Generally this is formatted in snake_case.
sourcepub fn route_name(self, route_name: impl AsRef<str>) -> Self
pub fn route_name(self, route_name: impl AsRef<str>) -> Self
Set the route_name for this Method.
This value will be used as part of the route for calling this method.
Routes have the form: /<package_name>.<service_name>/<method_route_name>
Generally this is formatted in PascalCase.
sourcepub fn comment(self, comment: impl AsRef<str>) -> Self
pub fn comment(self, comment: impl AsRef<str>) -> Self
Add a comment string that should be included as a doc comment for this Method.
sourcepub fn input_type(self, input_type: impl AsRef<str>) -> Self
pub fn input_type(self, input_type: impl AsRef<str>) -> Self
Set the path to the Rust type that should be use for the Request type of this method.
sourcepub fn output_type(self, output_type: impl AsRef<str>) -> Self
pub fn output_type(self, output_type: impl AsRef<str>) -> Self
Set the path to the Rust type that should be use for the Response type of this method.
sourcepub fn codec_path(self, codec_path: impl AsRef<str>) -> Self
pub fn codec_path(self, codec_path: impl AsRef<str>) -> Self
Set the path to the Rust type that should be used as the Codec
for this method.
Currently the codegen assumes that this type implements Default
.
sourcepub fn client_streaming(self) -> Self
pub fn client_streaming(self) -> Self
Sets if the Method request from the client is streamed.
sourcepub fn server_streaming(self) -> Self
pub fn server_streaming(self) -> Self
Sets if the Method response from the server is streamed.