@@ -4,4 +4,7 @@ members = [
|
||||
"tonic-build",
|
||||
"tonic-examples",
|
||||
"tonic-interop",
|
||||
|
||||
"tests/same_name",
|
||||
"tests/wellknown",
|
||||
]
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "same_name"
|
||||
version = "0.1.0"
|
||||
authors = ["Lucio Franco <luciofranco14@gmail.com>"]
|
||||
edition = "2018"
|
||||
publish = false
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
tonic = { path = "../../tonic" }
|
||||
bytes = "0.4"
|
||||
prost = "0.5"
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = { path = "../../tonic-build" }
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tonic_build::compile_protos("proto/foo.proto").unwrap();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package foo;
|
||||
|
||||
service Foo {
|
||||
rpc Foo(stream FooRequest) returns (stream FooResponse) {}
|
||||
}
|
||||
|
||||
message FooRequest {}
|
||||
|
||||
message FooResponse {}
|
||||
@@ -0,0 +1,3 @@
|
||||
pub mod pb {
|
||||
tonic::include_proto!("foo");
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "wellknown"
|
||||
version = "0.1.0"
|
||||
authors = ["Lucio Franco <luciofranco14@gmail.com>"]
|
||||
edition = "2018"
|
||||
publish = false
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
tonic = { path = "../../tonic" }
|
||||
bytes = "0.4"
|
||||
prost = "0.5"
|
||||
prost-types = "0.5"
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = { path = "../../tonic-build" }
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tonic_build::compile_protos("proto/wellknown.proto").unwrap();
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
pub mod pb {
|
||||
tonic::include_proto!("wellknown");
|
||||
}
|
||||
@@ -223,7 +223,7 @@ fn generate_unary(
|
||||
proto_path: &str,
|
||||
server_trait: Ident,
|
||||
) -> TokenStream {
|
||||
let service_ident = Ident::new(&method.proto_name, Span::call_site());
|
||||
let service_ident = quote::format_ident!("{}Svc", method.proto_name);
|
||||
|
||||
let (request, response) = crate::replace_wellknown(proto_path, &method);
|
||||
|
||||
@@ -262,7 +262,7 @@ fn generate_server_streaming(
|
||||
proto_path: &str,
|
||||
server_trait: Ident,
|
||||
) -> TokenStream {
|
||||
let service_ident = Ident::new(&method.proto_name, Span::call_site());
|
||||
let service_ident = quote::format_ident!("{}Svc", method.proto_name);
|
||||
|
||||
let (request, response) = crate::replace_wellknown(proto_path, &method);
|
||||
|
||||
@@ -305,7 +305,7 @@ fn generate_client_streaming(
|
||||
proto_path: &str,
|
||||
server_trait: Ident,
|
||||
) -> TokenStream {
|
||||
let service_ident = Ident::new(&method.proto_name, Span::call_site());
|
||||
let service_ident = quote::format_ident!("{}Svc", method.proto_name);
|
||||
|
||||
let (request, response) = crate::replace_wellknown(proto_path, &method);
|
||||
|
||||
@@ -346,7 +346,7 @@ fn generate_streaming(
|
||||
proto_path: &str,
|
||||
server_trait: Ident,
|
||||
) -> TokenStream {
|
||||
let service_ident = Ident::new(&method.proto_name, Span::call_site());
|
||||
let service_ident = quote::format_ident!("{}Svc", method.proto_name);
|
||||
|
||||
let (request, response) = crate::replace_wellknown(proto_path, &method);
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#[test]
|
||||
fn wellknown() {
|
||||
let tmp = std::env::temp_dir();
|
||||
tonic_build::configure()
|
||||
.out_dir(tmp)
|
||||
.format(false)
|
||||
.type_attribute(".", "#[derive(Serialize, Deserialize)]")
|
||||
.type_attribute(".", "#[serde(rename_all = \"camelCase\")]")
|
||||
.field_attribute("in", "#[serde(rename = \"in\")]")
|
||||
.compile(&["tests/protos/wellknown.proto"], &["tests/protos"])
|
||||
.unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user