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.
Trait Implementations§
source§impl Debug for MethodBuilder
impl Debug for MethodBuilder
source§impl Default for MethodBuilder
impl Default for MethodBuilder
source§fn default() -> MethodBuilder
fn default() -> MethodBuilder
Auto Trait Implementations§
impl Freeze for MethodBuilder
impl RefUnwindSafe for MethodBuilder
impl Send for MethodBuilder
impl Sync for MethodBuilder
impl Unpin for MethodBuilder
impl UnwindSafe for MethodBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more