summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof KosiƄski <krzysio@google.com>2023-10-19 01:17:52 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-10-19 01:17:52 +0000
commite07dd7410c1fb5218af86c43bd64adb53cc1a6af (patch)
tree7082704c3a9d3485299723b055b9f05a0a0de8e6
parentff8985682b5bfcd7f15a81fb358de1523cf403f4 (diff)
parent543450f90a0fcd8251438a75674c963021853b9f (diff)
downloadgrpcio-compiler-e07dd7410c1fb5218af86c43bd64adb53cc1a6af.tar.gz
Merge "Upgrade grpcio-compiler to 0.12.1" into main am: 8f5c92c714 am: bbc53266b1 am: 543450f90a
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/grpcio-compiler/+/2664079 Change-Id: I68c72fe8e3abf08cea096354125f4ac22d155e33 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--.cargo_vcs_info.json7
-rw-r--r--Android.bp4
-rw-r--r--Cargo.lock222
-rw-r--r--Cargo.toml32
-rw-r--r--Cargo.toml.orig8
-rw-r--r--METADATA12
-rw-r--r--src/codegen.rs21
-rw-r--r--src/prost_codegen.rs13
-rw-r--r--src/util.rs6
9 files changed, 168 insertions, 157 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 2587a95..814eaf3 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,6 @@
{
"git": {
- "sha1": "7a48e0bb843e702832c1c3ac024c468dedf0023c"
- }
-}
+ "sha1": "2e4a6d16a2c8816be3c65eafaf0a244ee68e0c8e"
+ },
+ "path_in_vcs": "compiler"
+} \ No newline at end of file
diff --git a/Android.bp b/Android.bp
index 36ef473..3b8f2de 100644
--- a/Android.bp
+++ b/Android.bp
@@ -37,7 +37,7 @@ rust_binary_host {
name: "grpc_rust_plugin",
crate_name: "grpc_rust_plugin",
cargo_env_compat: true,
- cargo_pkg_version: "0.9.0",
+ cargo_pkg_version: "0.12.1",
srcs: ["src/bin/grpc_rust_plugin.rs"],
edition: "2018",
features: [
@@ -55,7 +55,7 @@ rust_library_host {
name: "libgrpcio_compiler",
crate_name: "grpcio_compiler",
cargo_env_compat: true,
- cargo_pkg_version: "0.9.0",
+ cargo_pkg_version: "0.12.1",
srcs: ["src/lib.rs"],
edition: "2018",
features: [
diff --git a/Cargo.lock b/Cargo.lock
index 72a664e..75b2891 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,28 +1,30 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
+version = 3
+
[[package]]
name = "anyhow"
-version = "1.0.40"
+version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b"
+checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800"
[[package]]
name = "autocfg"
-version = "1.0.1"
+version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
+checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
-version = "1.2.1"
+version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bytes"
-version = "1.0.1"
+version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
+checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
[[package]]
name = "cfg-if"
@@ -43,30 +45,28 @@ dependencies = [
[[package]]
name = "either"
-version = "1.6.1"
+version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
+checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
[[package]]
-name = "fixedbitset"
-version = "0.2.0"
+name = "fastrand"
+version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
+checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
+dependencies = [
+ "instant",
+]
[[package]]
-name = "getrandom"
-version = "0.2.3"
+name = "fixedbitset"
+version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
-dependencies = [
- "cfg-if",
- "libc",
- "wasi",
-]
+checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]]
name = "grpcio-compiler"
-version = "0.9.0"
+version = "0.12.1"
dependencies = [
"derive-new",
"prost",
@@ -78,49 +78,61 @@ dependencies = [
[[package]]
name = "hashbrown"
-version = "0.9.1"
+version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
+checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "heck"
-version = "0.3.2"
+version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac"
-dependencies = [
- "unicode-segmentation",
-]
+checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "indexmap"
-version = "1.6.2"
+version = "1.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
+checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]]
+name = "instant"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
name = "itertools"
-version = "0.9.0"
+version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
+checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [
"either",
]
[[package]]
+name = "lazy_static"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
+
+[[package]]
name = "libc"
-version = "0.2.94"
+version = "0.2.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e"
+checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
[[package]]
name = "log"
-version = "0.4.14"
+version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
+checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if",
]
@@ -132,35 +144,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
[[package]]
+name = "once_cell"
+version = "1.17.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
+
+[[package]]
name = "petgraph"
-version = "0.5.1"
+version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7"
+checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4"
dependencies = [
"fixedbitset",
"indexmap",
]
[[package]]
-name = "ppv-lite86"
-version = "0.2.10"
+name = "prettyplease"
+version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
+checksum = "e97e3215779627f01ee256d2fad52f3d95e8e1c11e9fc6fd08f7cd455d5d5c78"
+dependencies = [
+ "proc-macro2",
+ "syn",
+]
[[package]]
name = "proc-macro2"
-version = "1.0.27"
+version = "1.0.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038"
+checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6"
dependencies = [
- "unicode-xid",
+ "unicode-ident",
]
[[package]]
name = "prost"
-version = "0.7.0"
+version = "0.11.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9e6984d2f1a23009bd270b8bb56d0926810a3d483f59c987d77969e9d8e840b2"
+checksum = "21dc42e00223fc37204bd4aa177e69420c604ca4a183209a8f9de30c6d934698"
dependencies = [
"bytes",
"prost-derive",
@@ -168,27 +190,31 @@ dependencies = [
[[package]]
name = "prost-build"
-version = "0.7.0"
+version = "0.11.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32d3ebd75ac2679c2af3a92246639f9fcc8a442ee420719cc4fe195b98dd5fa3"
+checksum = "a3f8ad728fb08fe212df3c05169e940fbb6d9d16a877ddde14644a983ba2012e"
dependencies = [
"bytes",
"heck",
"itertools",
+ "lazy_static",
"log",
"multimap",
"petgraph",
+ "prettyplease",
"prost",
"prost-types",
+ "regex",
+ "syn",
"tempfile",
"which",
]
[[package]]
name = "prost-derive"
-version = "0.7.0"
+version = "0.11.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "169a15f3008ecb5160cba7d37bcd690a7601b6d30cfb87a117d45e59d52af5d4"
+checksum = "8bda8c0881ea9f722eb9629376db3d0b903b462477c1aafcb0566610ac28ac5d"
dependencies = [
"anyhow",
"itertools",
@@ -199,9 +225,9 @@ dependencies = [
[[package]]
name = "prost-types"
-version = "0.7.0"
+version = "0.11.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b518d7cdd93dab1d1122cf07fa9a60771836c668dde9d9e2a139f957f0d9f1bb"
+checksum = "a5e0526209433e96d83d750dd81a99118edbc55739e7e61a46764fd2ad537788"
dependencies = [
"bytes",
"prost",
@@ -209,67 +235,42 @@ dependencies = [
[[package]]
name = "protobuf"
-version = "2.23.0"
+version = "2.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "45604fc7a88158e7d514d8e22e14ac746081e7a70d7690074dd0029ee37458d6"
+checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94"
[[package]]
name = "quote"
-version = "1.0.9"
+version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
+checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
dependencies = [
"proc-macro2",
]
[[package]]
-name = "rand"
-version = "0.8.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
-dependencies = [
- "libc",
- "rand_chacha",
- "rand_core",
- "rand_hc",
-]
-
-[[package]]
-name = "rand_chacha"
-version = "0.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
-dependencies = [
- "ppv-lite86",
- "rand_core",
-]
-
-[[package]]
-name = "rand_core"
-version = "0.6.2"
+name = "redox_syscall"
+version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
+checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [
- "getrandom",
+ "bitflags",
]
[[package]]
-name = "rand_hc"
-version = "0.3.0"
+name = "regex"
+version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
+checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733"
dependencies = [
- "rand_core",
+ "regex-syntax",
]
[[package]]
-name = "redox_syscall"
-version = "0.2.8"
+name = "regex-syntax"
+version = "0.6.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc"
-dependencies = [
- "bitflags",
-]
+checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
[[package]]
name = "remove_dir_all"
@@ -282,55 +283,44 @@ dependencies = [
[[package]]
name = "syn"
-version = "1.0.72"
+version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82"
+checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
dependencies = [
"proc-macro2",
"quote",
- "unicode-xid",
+ "unicode-ident",
]
[[package]]
name = "tempfile"
-version = "3.2.0"
+version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
+checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
dependencies = [
"cfg-if",
+ "fastrand",
"libc",
- "rand",
"redox_syscall",
"remove_dir_all",
"winapi",
]
[[package]]
-name = "unicode-segmentation"
-version = "1.7.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
-
-[[package]]
-name = "unicode-xid"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
-
-[[package]]
-name = "wasi"
-version = "0.10.2+wasi-snapshot-preview1"
+name = "unicode-ident"
+version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
+checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
[[package]]
name = "which"
-version = "4.1.0"
+version = "4.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b55551e42cbdf2ce2bedd2203d0cc08dba002c27510f86dab6d0ce304cba3dfe"
+checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
dependencies = [
"either",
"libc",
+ "once_cell",
]
[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 52cb1a5..be58771 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,22 +3,25 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g., crates.io) dependencies
+# to registry (e.g., crates.io) dependencies.
#
-# If you believe there's an error in this file please file an
-# issue against the rust-lang/cargo repository. If you're
-# editing this file be aware that the upstream Cargo.toml
-# will likely look very different (and much more reasonable)
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "grpcio-compiler"
-version = "0.9.0"
+version = "0.12.1"
authors = ["The TiKV Project Developers"]
description = "gRPC compiler for grpcio"
homepage = "https://github.com/tikv/grpc-rs"
documentation = "https://docs.rs/grpcio-compiler"
-keywords = ["compiler", "grpc", "protobuf"]
+keywords = [
+ "compiler",
+ "grpc",
+ "protobuf",
+]
categories = ["network-programming"]
license = "Apache-2.0"
repository = "https://github.com/tikv/grpc-rs"
@@ -30,20 +33,21 @@ required-features = ["protobuf-codec"]
[[bin]]
name = "grpc_rust_prost"
required-features = ["prost-codec"]
+
[dependencies.derive-new]
version = "0.5"
optional = true
[dependencies.prost]
-version = "0.7"
+version = "0.11"
optional = true
[dependencies.prost-build]
-version = "0.7"
+version = "0.11"
optional = true
[dependencies.prost-types]
-version = "0.7"
+version = "0.11"
optional = true
[dependencies.protobuf]
@@ -56,5 +60,11 @@ optional = true
[features]
default = ["protobuf-codec"]
-prost-codec = ["prost-build", "prost-types", "prost", "derive-new", "tempfile"]
+prost-codec = [
+ "prost-build",
+ "prost-types",
+ "prost",
+ "derive-new",
+ "tempfile",
+]
protobuf-codec = ["protobuf"]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 46c1e8b..9eb83a8 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "grpcio-compiler"
-version = "0.9.0"
+version = "0.12.1"
edition = "2018"
authors = ["The TiKV Project Developers"]
license = "Apache-2.0"
@@ -18,9 +18,9 @@ prost-codec = ["prost-build", "prost-types", "prost", "derive-new", "tempfile"]
[dependencies]
protobuf = { version = "2", optional = true }
-prost = { version = "0.7", optional = true }
-prost-build = { version = "0.7", optional = true }
-prost-types = { version = "0.7", optional = true }
+prost = { version = "0.11", optional = true }
+prost-build = { version = "0.11", optional = true }
+prost-types = { version = "0.11", optional = true }
derive-new = { version = "0.5", optional = true }
tempfile = { version = "3.0", optional = true }
diff --git a/METADATA b/METADATA
index 01fad1f..0252235 100644
--- a/METADATA
+++ b/METADATA
@@ -1,3 +1,7 @@
+# This project was upgraded with external_updater.
+# Usage: tools/external_updater/updater.sh update rust/crates/grpcio-compiler
+# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
+
name: "grpcio-compiler"
description: "gRPC compiler for grpcio"
third_party {
@@ -7,13 +11,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/grpcio-compiler/grpcio-compiler-0.9.0.crate"
+ value: "https://static.crates.io/crates/grpcio-compiler/grpcio-compiler-0.12.1.crate"
}
- version: "0.9.0"
+ version: "0.12.1"
license_type: NOTICE
last_upgrade_date {
- year: 2021
+ year: 2023
month: 6
- day: 21
+ day: 20
}
}
diff --git a/src/codegen.rs b/src/codegen.rs
index e2f6c10..20cabc3 100644
--- a/src/codegen.rs
+++ b/src/codegen.rs
@@ -111,7 +111,7 @@ impl<'a> CodeWriter<'a> {
where
F: Fn(&mut CodeWriter),
{
- self.block(&format!("{} {{", prefix), "}", cb);
+ self.block(&format!("{prefix} {{"), "}", cb);
}
pub fn impl_self_block<S: AsRef<str>, F>(&mut self, name: S, cb: F)
@@ -132,22 +132,22 @@ impl<'a> CodeWriter<'a> {
where
F: Fn(&mut CodeWriter),
{
- self.expr_block(&format!("pub trait {}", name), cb);
+ self.expr_block(&format!("pub trait {name}"), cb);
}
pub fn field_entry(&mut self, name: &str, value: &str) {
- self.write_line(&format!("{}: {},", name, value));
+ self.write_line(&format!("{name}: {value},"));
}
pub fn field_decl(&mut self, name: &str, field_type: &str) {
- self.write_line(&format!("{}: {},", name, field_type));
+ self.write_line(&format!("{name}: {field_type},"));
}
pub fn comment(&mut self, comment: &str) {
if comment.is_empty() {
self.write_line("//");
} else {
- self.write_line(&format!("// {}", comment));
+ self.write_line(&format!("// {comment}"));
}
}
@@ -156,9 +156,9 @@ impl<'a> CodeWriter<'a> {
F: Fn(&mut CodeWriter),
{
if public {
- self.expr_block(&format!("pub fn {}", sig), cb);
+ self.expr_block(&format!("pub fn {sig}"), cb);
} else {
- self.expr_block(&format!("fn {}", sig), cb);
+ self.expr_block(&format!("fn {sig}"), cb);
}
}
@@ -575,7 +575,10 @@ impl<'a> ServiceGen<'a> {
fn write_client(&self, w: &mut CodeWriter) {
w.write_line("#[derive(Clone)]");
w.pub_struct(&self.client_name(), |w| {
- w.field_decl("client", "::grpcio::Client");
+ // This can also be exposed by a method. But it may introduce a name conflict
+ // between service definition and method name. Marking it public may put extra
+ // restrict on compatability, but it should not be an issue.
+ w.field_decl("pub client", "::grpcio::Client");
});
w.write_line("");
@@ -592,7 +595,7 @@ impl<'a> ServiceGen<'a> {
method.write_client(w);
}
w.pub_fn(
- "spawn<F>(&self, f: F) where F: ::futures::Future<Output = ()> + Send + 'static",
+ "spawn<F>(&self, f: F) where F: ::std::future::Future<Output = ()> + Send + 'static",
|w| {
w.write_line("self.client.spawn(f)");
},
diff --git a/src/prost_codegen.rs b/src/prost_codegen.rs
index 4457c02..87720b0 100644
--- a/src/prost_codegen.rs
+++ b/src/prost_codegen.rs
@@ -6,7 +6,7 @@ use std::{env, fs, io, process::Command, str};
use derive_new::new;
use prost::Message;
-use prost_build::{protoc, protoc_include, Config, Method, Service, ServiceGenerator};
+use prost_build::{Config, Method, Service, ServiceGenerator};
use prost_types::FileDescriptorSet;
use crate::util::{fq_grpc, to_snake_case, MethodType};
@@ -22,9 +22,10 @@ where
// Create a file descriptor set for the protocol files.
let tmp = tempfile::Builder::new().prefix("prost-build").tempdir()?;
+ std::fs::create_dir_all(tmp.path())?;
let descriptor_set = tmp.path().join("prost-descriptor-set");
- let mut cmd = Command::new(protoc());
+ let mut cmd = Command::new(prost_build::protoc_from_env());
cmd.arg("--include_imports")
.arg("--include_source_info")
.arg("-o")
@@ -36,7 +37,9 @@ where
// Set the protoc include after the user includes in case the user wants to
// override one of the built-in .protos.
- cmd.arg("-I").arg(protoc_include());
+ if let Some(inc) = prost_build::protoc_include_from_env() {
+ cmd.arg("-I").arg(inc);
+ }
for proto in protos {
cmd.arg(proto.as_ref());
@@ -164,7 +167,7 @@ fn generate_client(service: &Service, buf: &mut String) {
buf.push_str("#[derive(Clone)]\n");
buf.push_str("pub struct ");
buf.push_str(&client_name);
- buf.push_str(" { client: ::grpcio::Client }\n");
+ buf.push_str(" { pub client: ::grpcio::Client }\n");
buf.push_str("impl ");
buf.push_str(&client_name);
@@ -439,7 +442,7 @@ impl<'a> ClientMethod<'a> {
fn generate_spawn(buf: &mut String) {
buf.push_str(
"pub fn spawn<F>(&self, f: F) \
- where F: ::futures::Future<Output = ()> + Send + 'static {\
+ where F: ::std::future::Future<Output = ()> + Send + 'static {\
self.client.spawn(f)\
}\n",
);
diff --git a/src/util.rs b/src/util.rs
index e6ff936..e9a6b33 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -82,7 +82,7 @@ pub fn to_camel_case(name: &str) -> String {
}
pub fn fq_grpc(item: &str) -> String {
- format!("::grpcio::{}", item)
+ format!("::grpcio::{item}")
}
pub enum MethodType {
@@ -125,7 +125,7 @@ mod test {
];
for (origin, exp) in cases {
- let res = super::to_snake_case(&origin);
+ let res = super::to_snake_case(origin);
assert_eq!(res, exp);
}
}
@@ -148,7 +148,7 @@ mod test {
];
for (origin, exp) in cases {
- let res = super::to_camel_case(&origin);
+ let res = super::to_camel_case(origin);
assert_eq!(res, exp);
}
}