From 7e4bd7afc99a50af6613d9d5d237260933334929 Mon Sep 17 00:00:00 2001 From: Yu Ding Date: Sat, 24 Mar 2018 00:33:22 -0700 Subject: [PATCH] v0.9.8 release --- Readme.md | 2 +- release_notes.md | 5 +- samplecode/protobuf/Makefile | 183 + samplecode/protobuf/app/Cargo.toml | 10 + samplecode/protobuf/app/build.rs | 41 + samplecode/protobuf/app/src/main.rs | 163 + samplecode/protobuf/bin/readme.txt | 1 + samplecode/protobuf/enclave/Cargo.toml | 18 + .../protobuf/enclave/Enclave.config.xml | 12 + samplecode/protobuf/enclave/Enclave.edl | 42 + samplecode/protobuf/enclave/Enclave.lds | 9 + .../protobuf/enclave/Enclave_private.pem | 39 + samplecode/protobuf/enclave/Makefile | 43 + samplecode/protobuf/enclave/Xargo.toml | 25 + samplecode/protobuf/enclave/src/lib.rs | 63 + .../enclave/x86_64-unknown-linux-sgx.json | 31 + samplecode/protobuf/lib/readme.txt | 1 + samplecode/protobuf/person.proto | 5 + samplecode/test_all.sh | 1 + third_party/protobuf/Cargo.toml | 44 + third_party/protobuf/Cargo.toml.orig | 33 + third_party/protobuf/README.md | 28 + third_party/protobuf/Xargo.toml | 14 + .../protobuf/benches/coded_input_stream.rs | 102 + .../protobuf/benches/coded_output_stream.rs | 48 + third_party/protobuf/build.sh | 8 + third_party/protobuf/full-rebuild.sh | 31 + .../protobuf-bin-gen-rust-do-not-use.rs | 36 + third_party/protobuf/protoc-gen-rust.rs | 8 + third_party/protobuf/regenerate.sh | 49 + third_party/protobuf/src/buf_read_iter.rs | 436 + third_party/protobuf/src/cached_size.rs | 25 + third_party/protobuf/src/chars.rs | 96 + third_party/protobuf/src/clear.rs | 35 + third_party/protobuf/src/code_writer.rs | 364 + third_party/protobuf/src/codegen/enums.rs | 266 + .../protobuf/src/codegen/extensions.rs | 91 + third_party/protobuf/src/codegen/field.rs | 2065 +++ third_party/protobuf/src/codegen/message.rs | 473 + third_party/protobuf/src/codegen/mod.rs | 171 + .../protobuf/src/codegen/rust_types_values.rs | 505 + .../protobuf/src/codegen/well_known_types.rs | 63 + third_party/protobuf/src/compiler_plugin.rs | 37 + third_party/protobuf/src/descriptor.rs | 10826 ++++++++++++++++ third_party/protobuf/src/descriptorx.rs | 623 + third_party/protobuf/src/error.rs | 105 + third_party/protobuf/src/ext.rs | 31 + third_party/protobuf/src/hex.rs | 80 + third_party/protobuf/src/lazy.rs | 90 + third_party/protobuf/src/lib.rs | 115 + third_party/protobuf/src/misc.rs | 38 + third_party/protobuf/src/paginate.rs | 35 + third_party/protobuf/src/plugin.rs | 1080 ++ third_party/protobuf/src/protocore.rs | 239 + third_party/protobuf/src/reflect/accessor.rs | 1144 ++ third_party/protobuf/src/reflect/map.rs | 68 + third_party/protobuf/src/reflect/mod.rs | 404 + third_party/protobuf/src/reflect/optional.rs | 50 + third_party/protobuf/src/reflect/repeated.rs | 225 + third_party/protobuf/src/reflect/value.rs | 163 + third_party/protobuf/src/repeated.rs | 368 + third_party/protobuf/src/rt.rs | 798 ++ third_party/protobuf/src/rust.rs | 123 + third_party/protobuf/src/rustproto.rs | 164 + third_party/protobuf/src/singular.rs | 448 + third_party/protobuf/src/stream.rs | 1475 +++ third_party/protobuf/src/strx.rs | 35 + third_party/protobuf/src/text_format.rs | 291 + third_party/protobuf/src/types.rs | 561 + third_party/protobuf/src/unknown.rs | 212 + third_party/protobuf/src/varint.rs | 35 + .../protobuf/src/well_known_types/any.rs | 409 + .../protobuf/src/well_known_types/api.rs | 1465 +++ .../protobuf/src/well_known_types/duration.rs | 377 + .../protobuf/src/well_known_types/empty.rs | 244 + .../src/well_known_types/field_mask.rs | 417 + .../protobuf/src/well_known_types/mod.rs | 23 + .../src/well_known_types/source_context.rs | 288 + .../src/well_known_types/struct_pb.rs | 1077 ++ .../src/well_known_types/timestamp.rs | 379 + .../protobuf/src/well_known_types/type_pb.rs | 2531 ++++ .../protobuf/src/well_known_types/wrappers.rs | 1717 +++ third_party/protobuf/src/zigzag.rs | 50 + .../protobuf/x86_64-unknown-linux-sgx.json | 31 + 84 files changed, 34554 insertions(+), 2 deletions(-) create mode 100644 samplecode/protobuf/Makefile create mode 100644 samplecode/protobuf/app/Cargo.toml create mode 100644 samplecode/protobuf/app/build.rs create mode 100644 samplecode/protobuf/app/src/main.rs create mode 100644 samplecode/protobuf/bin/readme.txt create mode 100644 samplecode/protobuf/enclave/Cargo.toml create mode 100644 samplecode/protobuf/enclave/Enclave.config.xml create mode 100644 samplecode/protobuf/enclave/Enclave.edl create mode 100644 samplecode/protobuf/enclave/Enclave.lds create mode 100644 samplecode/protobuf/enclave/Enclave_private.pem create mode 100644 samplecode/protobuf/enclave/Makefile create mode 100644 samplecode/protobuf/enclave/Xargo.toml create mode 100644 samplecode/protobuf/enclave/src/lib.rs create mode 100644 samplecode/protobuf/enclave/x86_64-unknown-linux-sgx.json create mode 100644 samplecode/protobuf/lib/readme.txt create mode 100644 samplecode/protobuf/person.proto create mode 100644 third_party/protobuf/Cargo.toml create mode 100644 third_party/protobuf/Cargo.toml.orig create mode 100644 third_party/protobuf/README.md create mode 100644 third_party/protobuf/Xargo.toml create mode 100644 third_party/protobuf/benches/coded_input_stream.rs create mode 100644 third_party/protobuf/benches/coded_output_stream.rs create mode 100755 third_party/protobuf/build.sh create mode 100755 third_party/protobuf/full-rebuild.sh create mode 100644 third_party/protobuf/protobuf-bin-gen-rust-do-not-use.rs create mode 100644 third_party/protobuf/protoc-gen-rust.rs create mode 100755 third_party/protobuf/regenerate.sh create mode 100644 third_party/protobuf/src/buf_read_iter.rs create mode 100644 third_party/protobuf/src/cached_size.rs create mode 100644 third_party/protobuf/src/chars.rs create mode 100644 third_party/protobuf/src/clear.rs create mode 100644 third_party/protobuf/src/code_writer.rs create mode 100644 third_party/protobuf/src/codegen/enums.rs create mode 100644 third_party/protobuf/src/codegen/extensions.rs create mode 100644 third_party/protobuf/src/codegen/field.rs create mode 100644 third_party/protobuf/src/codegen/message.rs create mode 100644 third_party/protobuf/src/codegen/mod.rs create mode 100644 third_party/protobuf/src/codegen/rust_types_values.rs create mode 100644 third_party/protobuf/src/codegen/well_known_types.rs create mode 100644 third_party/protobuf/src/compiler_plugin.rs create mode 100644 third_party/protobuf/src/descriptor.rs create mode 100644 third_party/protobuf/src/descriptorx.rs create mode 100644 third_party/protobuf/src/error.rs create mode 100644 third_party/protobuf/src/ext.rs create mode 100644 third_party/protobuf/src/hex.rs create mode 100644 third_party/protobuf/src/lazy.rs create mode 100644 third_party/protobuf/src/lib.rs create mode 100644 third_party/protobuf/src/misc.rs create mode 100644 third_party/protobuf/src/paginate.rs create mode 100644 third_party/protobuf/src/plugin.rs create mode 100644 third_party/protobuf/src/protocore.rs create mode 100644 third_party/protobuf/src/reflect/accessor.rs create mode 100644 third_party/protobuf/src/reflect/map.rs create mode 100644 third_party/protobuf/src/reflect/mod.rs create mode 100644 third_party/protobuf/src/reflect/optional.rs create mode 100644 third_party/protobuf/src/reflect/repeated.rs create mode 100644 third_party/protobuf/src/reflect/value.rs create mode 100644 third_party/protobuf/src/repeated.rs create mode 100644 third_party/protobuf/src/rt.rs create mode 100644 third_party/protobuf/src/rust.rs create mode 100644 third_party/protobuf/src/rustproto.rs create mode 100644 third_party/protobuf/src/singular.rs create mode 100644 third_party/protobuf/src/stream.rs create mode 100644 third_party/protobuf/src/strx.rs create mode 100644 third_party/protobuf/src/text_format.rs create mode 100644 third_party/protobuf/src/types.rs create mode 100644 third_party/protobuf/src/unknown.rs create mode 100644 third_party/protobuf/src/varint.rs create mode 100644 third_party/protobuf/src/well_known_types/any.rs create mode 100644 third_party/protobuf/src/well_known_types/api.rs create mode 100644 third_party/protobuf/src/well_known_types/duration.rs create mode 100644 third_party/protobuf/src/well_known_types/empty.rs create mode 100644 third_party/protobuf/src/well_known_types/field_mask.rs create mode 100644 third_party/protobuf/src/well_known_types/mod.rs create mode 100644 third_party/protobuf/src/well_known_types/source_context.rs create mode 100644 third_party/protobuf/src/well_known_types/struct_pb.rs create mode 100644 third_party/protobuf/src/well_known_types/timestamp.rs create mode 100644 third_party/protobuf/src/well_known_types/type_pb.rs create mode 100644 third_party/protobuf/src/well_known_types/wrappers.rs create mode 100644 third_party/protobuf/src/zigzag.rs create mode 100644 third_party/protobuf/x86_64-unknown-linux-sgx.json diff --git a/Readme.md b/Readme.md index 3818648d4..5c3394c8d 100644 --- a/Readme.md +++ b/Readme.md @@ -2,7 +2,7 @@ Rust SGX SDK helps developers write Intel SGX applications in Rust programming language. [[Paper pdf]](documents/ccsp17.pdf) ## v0.9.8 Release -This version provides security updates regards to recent Spectre attacks in Intel SGX, and supports **Rust stable (2018-03-01)** (in branch named 'rust-stable'). It contains support of [Intel SGX SDK 2.1.2](https://download.01.org/intel-sgx/linux-2.1.2/) and a series of API functions to stop speculative execution on demand. Please refer to [release_notes](release_notes.md) for further details. +This version provides security updates regards to recent Spectre attacks in Intel SGX, and supports **Rust stable (2018-03-01)** (in branch named 'rust-stable'). It contains support of [Intel SGX SDK 2.1.2](https://download.01.org/intel-sgx/linux-2.1.2/) and a series of API functions to stop speculative execution on demand. In addition, we provide a ported version of [rust-protobuf](https://crates.io/crates/protobuf) v1.4.4. Please refer to [release_notes](release_notes.md) for further details. ## v0.9.7 Release This version provides a new namespace: `sgx_tstd::untrusted`, including `sgx_tstd::untrusted::fs` `sgx_tstd::untrusted::time` and `sgx_tstd::untrusted::path`, providing supports to operation to ocalls in a **untrusted** namespace. The **untrusted** namespace is always enabled no matter `untrusted_*` is set or not. We **urge** the developers to use the `sgx_tstd::untrusted` namespace to port their crates, instead of using the `untrusted_` series of features. Also, we renamed the `untrusted_net` feature to `net` for feature name unification. Please refer to [release_notes](release_notes.md) for further details. diff --git a/release_notes.md b/release_notes.md index c9ce86fb7..3bc885088 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,4 +1,7 @@ # Rust SGX SDK v0.9.8 Release Notes + +**New branch rust-stable** We provide a new branch to support stable channel of Rust in a new branch 'rust-stable'. It contains modified libraries and a customized xargo. The customized cargo allows Rust stable to compile sysroot by demonstrating `RUSTC_BOOTSTRAP` as a env var. We provide a new docker image `baiduxlab/sgx-rust-stable` as long as its [dockerfile](dockerfile/rust-stable). + **Support Intel SGX SDK v2.1.2** **Support Rust nightly 2018-03-16** @@ -7,7 +10,7 @@ **New API `rsgx_is_enclave_crashed`** We provide `sgx_trts::rsgx_is_enclave_crashed` corresponding to a new feature of Intel SGX SDK 2.1.2. -**New branch rust-stable** We provide a new branch to support stable channel of Rust (stable-2018-03-01) in a new branch 'rust-stable'. It contains modified libraries and a customized xargo. The customized cargo allows Rust stable to compile sysroot by demonstrating `RUSTC_BOOTSTRAP` as a env var. We provide a new docker image `baiduxlab/sgx-rust-stable` as long as its [dockerfile](dockerfile/rust-stable). +**rust-protobuf** We provide a ported [protobuf](https://crates.io/crates/protobuf) library for SGX enclave at [protobuf](third_party/protobuf). And we provide an example showing how to use it at [protobuf code sample](samplecode/protobuf). Attention: please install the rust-protobuf compiler by `cargo install protobuf --vers=1.4.4` before build the sample project. # Rust SGX SDK v0.9.7 Release Notes **Provide `sgx_tstd::untrusted` namespace** v0.9.7 provides `sgx_tstd::untrusted::{fs,path,time}` which are related to ocall functions. They are always enabled no matter `untrusted_fs` or `untrusted_time` feature is enabled or not. The major concern of providing such a namespace is that we want the developer to know they are invoking ocall related functions that brings **untrusted data** into the **trusted** execution engine. For the best security practice, explicitly importing from `sgx_tstd::untrusted` is better than enabling feature in `Cargo.toml`. We stress that `untrusted_fs` and `untrusted_time` features are designed to be **contingency plans** and should only be enabled when porting a very complex Rust crate to a Rust-SGX enclave. diff --git a/samplecode/protobuf/Makefile b/samplecode/protobuf/Makefile new file mode 100644 index 000000000..f95675c5b --- /dev/null +++ b/samplecode/protobuf/Makefile @@ -0,0 +1,183 @@ +# Copyright (C) 2017-2018 Baidu, Inc. All Rights Reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Baidu, Inc., nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +######## SGX SDK Settings ######## + +SGX_SDK ?= /opt/intel/sgxsdk +SGX_MODE ?= HW +SGX_ARCH ?= x64 + +ifeq ($(shell getconf LONG_BIT), 32) + SGX_ARCH := x86 +else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32) + SGX_ARCH := x86 +endif + +ifeq ($(SGX_ARCH), x86) + SGX_COMMON_CFLAGS := -m32 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r +else + SGX_COMMON_CFLAGS := -m64 + SGX_LIBRARY_PATH := $(SGX_SDK)/lib64 + SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign + SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r +endif + +ifeq ($(SGX_DEBUG), 1) +ifeq ($(SGX_PRERELEASE), 1) +$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!) +endif +endif + + +ifeq ($(SGX_DEBUG), 1) + SGX_COMMON_CFLAGS += -O0 -g +else + SGX_COMMON_CFLAGS += -O2 +endif + +######## CUSTOM Settings ######## + +CUSTOM_LIBRARY_PATH := ./lib +CUSTOM_BIN_PATH := ./bin +CUSTOM_EDL_PATH := ../../edl + +######## EDL Settings ######## + +Enclave_EDL_Files := enclave/Enclave_t.c enclave/Enclave_t.h app/Enclave_u.c app/Enclave_u.h + +######## protobuf Settings ######## + +Proto_File := ./person.proto +Proto_RS_Files := ./app/src/person.rs ./enclave/src/person.rs + +######## APP Settings ######## + +App_Rust_Flags := --release +App_Include_Paths := -I ./app -I./include -I$(SGX_SDK)/include +App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) + +App_Rust_Path := ./app/target/release +App_Enclave_u_Object :=app/libEnclave_u.a +App_Name := bin/app + +######## Enclave Settings ######## + +ifneq ($(SGX_MODE), HW) + Trts_Library_Name := sgx_trts_sim + Service_Library_Name := sgx_tservice_sim +else + Trts_Library_Name := sgx_trts + Service_Library_Name := sgx_tservice +endif +Crypto_Library_Name := sgx_tcrypto +KeyExchange_Library_Name := sgx_tkey_exchange +ProtectedFs_Library_Name := sgx_tprotected_fs + +RustEnclave_C_Files := $(wildcard ./enclave/*.c) +RustEnclave_C_Objects := $(RustEnclave_C_Files:.c=.o) +RustEnclave_Include_Paths := -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport -I$(SGX_SDK)/include/epid -I ./enclave -I./include + +RustEnclave_Link_Libs := -L$(CUSTOM_LIBRARY_PATH) -lcompiler-rt-patch -lenclave +RustEnclave_Compile_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(RustEnclave_Include_Paths) +RustEnclave_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \ + -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \ + -Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -l$(Crypto_Library_Name) $(RustEnclave_Link_Libs) -Wl,--end-group \ + -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \ + -Wl,-pie,-eenclave_entry -Wl,--export-dynamic \ + -Wl,--defsym,__ImageBase=0 \ + -Wl,--gc-sections \ + -Wl,--version-script=enclave/Enclave.lds + +RustEnclave_Name := enclave/enclave.so +Signed_RustEnclave_Name := bin/enclave.signed.so + +.PHONY: all +all: $(App_Name) $(Signed_RustEnclave_Name) + +######## EDL Objects ######## + +$(Enclave_EDL_Files): $(SGX_EDGER8R) enclave/Enclave.edl + $(SGX_EDGER8R) --trusted enclave/Enclave.edl --search-path $(SGX_SDK)/include --search-path ../../edl --trusted-dir enclave + $(SGX_EDGER8R) --untrusted enclave/Enclave.edl --search-path $(SGX_SDK)/include --search-path ../../edl --untrusted-dir app + @echo "GEN => $(Enclave_EDL_Files)" + +####### protobuf ####### + +$(Proto_RS_Files): $(Proto_File) + protoc --rust_out ./app/src $(Proto_File) + protoc --rust_out ./enclave/src $(Proto_File) + sed -i -e 's/#!\[allow(unused_results)\]/#!\[allow(unused_results)\]\n\nuse std::prelude::v1::*;\n/g' ./enclave/src/person.rs + +######## App Objects ######## + +app/Enclave_u.o: $(Enclave_EDL_Files) + @$(CC) $(App_C_Flags) -c app/Enclave_u.c -o $@ + @echo "CC <= $<" + +$(App_Enclave_u_Object): app/Enclave_u.o + $(AR) rcsD $@ $^ + cp $(App_Enclave_u_Object) ./lib + +$(App_Name): $(App_Enclave_u_Object) $(Proto_RS_Files) + @cd app && SGX_SDK=$(SGX_SDK) cargo build $(App_Rust_Flags) + @echo "Cargo => $@" + cp $(App_Rust_Path)/app ./bin + +######## Enclave Objects ######## + +enclave/Enclave_t.o: $(Enclave_EDL_Files) + @$(CC) $(RustEnclave_Compile_Flags) -c enclave/Enclave_t.c -o $@ + @echo "CC <= $<" + +$(RustEnclave_Name): enclave compiler-rt enclave/Enclave_t.o + cp ../../compiler-rt/libcompiler-rt-patch.a ./lib + @$(CXX) enclave/Enclave_t.o -o $@ $(RustEnclave_Link_Flags) + @echo "LINK => $@" + +$(Signed_RustEnclave_Name): $(RustEnclave_Name) + @$(SGX_ENCLAVE_SIGNER) sign -key enclave/Enclave_private.pem -enclave $(RustEnclave_Name) -out $@ -config enclave/Enclave.config.xml + @echo "SIGN => $@" + +.PHONY: enclave +enclave: $(Proto_RS_FILES) + $(MAKE) -C ./enclave/ + +.PHONY: compiler-rt +compiler-rt: + $(MAKE) -C ../../compiler-rt/ 2> /dev/null + +.PHONY: clean +clean: + @rm -f $(App_Name) $(RustEnclave_Name) $(Signed_RustEnclave_Name) enclave/*_t.* app/*_u.* lib/*.a $(Proto_RS_Files) + @cd enclave && cargo clean && rm -f Cargo.lock + @cd app && cargo clean && rm -f Cargo.lock + diff --git a/samplecode/protobuf/app/Cargo.toml b/samplecode/protobuf/app/Cargo.toml new file mode 100644 index 000000000..00a4c76db --- /dev/null +++ b/samplecode/protobuf/app/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "app" +version = "0.9.7" +authors = ["duanran01 "] +build = "build.rs" + +[dependencies] +sgx_types = { path = "../../../sgx_types" } +sgx_urts = { path = "../../../sgx_urts" } +protobuf = "1.4.4" diff --git a/samplecode/protobuf/app/build.rs b/samplecode/protobuf/app/build.rs new file mode 100644 index 000000000..afdd088ed --- /dev/null +++ b/samplecode/protobuf/app/build.rs @@ -0,0 +1,41 @@ +// Copyright (C) 2017-2018 Baidu, Inc. All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in +// the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Baidu, Inc., nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +use std::env; + +fn main () { + + let sdk_dir = env::var("SGX_SDK") + .unwrap_or_else(|_| "/opt/intel/sgxsdk".to_string()); + + println!("cargo:rustc-link-search=native=../lib"); + println!("cargo:rustc-link-lib=static=Enclave_u"); + + println!("cargo:rustc-link-search=native={}/lib64", sdk_dir); + println!("cargo:rustc-link-lib=dylib=sgx_urts"); +} diff --git a/samplecode/protobuf/app/src/main.rs b/samplecode/protobuf/app/src/main.rs new file mode 100644 index 000000000..7cf3559b1 --- /dev/null +++ b/samplecode/protobuf/app/src/main.rs @@ -0,0 +1,163 @@ +// Copyright (C) 2017-2018 Baidu, Inc. All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in +// the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Baidu, Inc., nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +extern crate sgx_types; +extern crate sgx_urts; +extern crate protobuf; + +use sgx_types::*; +use sgx_urts::SgxEnclave; + +use std::io::{Read, Write}; +use std::fs; +use std::path; +use std::env; + +mod person; +use person::Person; +use protobuf::Message; +use protobuf::hex::encode_hex; + +static ENCLAVE_FILE: &'static str = "enclave.signed.so"; +static ENCLAVE_TOKEN: &'static str = "enclave.token"; + +extern { + fn say_something(eid: sgx_enclave_id_t, retval: *mut sgx_status_t, + some_string: *const u8, len: usize) -> sgx_status_t; +} + +fn init_enclave() -> SgxResult { + + let mut launch_token: sgx_launch_token_t = [0; 1024]; + let mut launch_token_updated: i32 = 0; + // Step 1: try to retrieve the launch token saved by last transaction + // if there is no token, then create a new one. + // + // try to get the token saved in $HOME */ + let mut home_dir = path::PathBuf::new(); + let use_token = match env::home_dir() { + Some(path) => { + println!("[+] Home dir is {}", path.display()); + home_dir = path; + true + }, + None => { + println!("[-] Cannot get home dir"); + false + } + }; + + let token_file: path::PathBuf = home_dir.join(ENCLAVE_TOKEN);; + if use_token == true { + match fs::File::open(&token_file) { + Err(_) => { + println!("[-] Open token file {} error! Will create one.", token_file.as_path().to_str().unwrap()); + }, + Ok(mut f) => { + println!("[+] Open token file success! "); + match f.read(&mut launch_token) { + Ok(1024) => { + println!("[+] Token file valid!"); + }, + _ => println!("[+] Token file invalid, will create new token file"), + } + } + } + } + + // Step 2: call sgx_create_enclave to initialize an enclave instance + // Debug Support: set 2nd parameter to 1 + let debug = 1; + let mut misc_attr = sgx_misc_attribute_t {secs_attr: sgx_attributes_t { flags:0, xfrm:0}, misc_select:0}; + let enclave = try!(SgxEnclave::create(ENCLAVE_FILE, + debug, + &mut launch_token, + &mut launch_token_updated, + &mut misc_attr)); + + // Step 3: save the launch token if it is updated + if use_token == true && launch_token_updated != 0 { + // reopen the file with write capablity + match fs::File::create(&token_file) { + Ok(mut f) => { + match f.write_all(&launch_token) { + Ok(()) => println!("[+] Saved updated launch token!"), + Err(_) => println!("[-] Failed to save updated launch token!"), + } + }, + Err(_) => { + println!("[-] Failed to save updated enclave token, but doesn't matter"); + }, + } + } + + Ok(enclave) +} + +fn main() { + + let enclave = match init_enclave() { + Ok(r) => { + println!("[+] Init Enclave Successful {}!", r.geteid()); + r + }, + Err(x) => { + println!("[-] Init Enclave Failed {}!", x.as_str()); + return; + }, + }; + + let mut one_person = Person::new(); + one_person.set_name("David".to_string()); + one_person.set_id(0x12345678); + one_person.set_email("david@foo.com".to_string()); + +// let input_string = String::from("This is a normal world string passed into Enclave!\n"); + let input_string = encode_hex(&one_person.write_to_bytes().unwrap()); + + let mut retval = sgx_status_t::SGX_SUCCESS; + + let result = unsafe { + say_something(enclave.geteid(), + &mut retval, + input_string.as_ptr() as * const u8, + input_string.len()) + }; + + match result { + sgx_status_t::SGX_SUCCESS => {}, + _ => { + println!("[-] ECALL Enclave Failed {}!", result.as_str()); + return; + } + } + + println!("[+] say_something success..."); + + enclave.destroy(); +} diff --git a/samplecode/protobuf/bin/readme.txt b/samplecode/protobuf/bin/readme.txt new file mode 100644 index 000000000..c5e82d745 --- /dev/null +++ b/samplecode/protobuf/bin/readme.txt @@ -0,0 +1 @@ +bin \ No newline at end of file diff --git a/samplecode/protobuf/enclave/Cargo.toml b/samplecode/protobuf/enclave/Cargo.toml new file mode 100644 index 000000000..a88bbd585 --- /dev/null +++ b/samplecode/protobuf/enclave/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "Helloworldsampleenclave" +version = "0.9.7" +authors = ["Baidu"] + +[lib] +name = "helloworldsampleenclave" +crate-type = ["staticlib"] + +[features] +default = [] + +[target.'cfg(not(target_env = "sgx"))'.dependencies] +sgx_types = { path = "../../../sgx_types" } +sgx_tstd = { path = "../../../sgx_tstd" } + +[dependencies] +protobuf = { path = "../../../third_party/protobuf" } diff --git a/samplecode/protobuf/enclave/Enclave.config.xml b/samplecode/protobuf/enclave/Enclave.config.xml new file mode 100644 index 000000000..ee4c3f78c --- /dev/null +++ b/samplecode/protobuf/enclave/Enclave.config.xml @@ -0,0 +1,12 @@ + + + 0 + 0 + 0x40000 + 0x100000 + 1 + 1 + 0 + 0 + 0xFFFFFFFF + diff --git a/samplecode/protobuf/enclave/Enclave.edl b/samplecode/protobuf/enclave/Enclave.edl new file mode 100644 index 000000000..b33b964a3 --- /dev/null +++ b/samplecode/protobuf/enclave/Enclave.edl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2017-2018 Baidu, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Baidu, Inc., nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +enclave { + from "sgx_tstd.edl" import *; + from "sgx_stdio.edl" import *; + from "sgx_backtrace.edl" import *; + from "sgx_tstdc.edl" import *; + trusted { + /* define ECALLs here. */ + + public sgx_status_t say_something([in, size=len] const uint8_t* some_string, size_t len); + }; +}; diff --git a/samplecode/protobuf/enclave/Enclave.lds b/samplecode/protobuf/enclave/Enclave.lds new file mode 100644 index 000000000..e3d9d0ee0 --- /dev/null +++ b/samplecode/protobuf/enclave/Enclave.lds @@ -0,0 +1,9 @@ +enclave.so +{ + global: + g_global_data_sim; + g_global_data; + enclave_entry; + local: + *; +}; diff --git a/samplecode/protobuf/enclave/Enclave_private.pem b/samplecode/protobuf/enclave/Enclave_private.pem new file mode 100644 index 000000000..529d07be3 --- /dev/null +++ b/samplecode/protobuf/enclave/Enclave_private.pem @@ -0,0 +1,39 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIG4gIBAAKCAYEAroOogvsj/fZDZY8XFdkl6dJmky0lRvnWMmpeH41Bla6U1qLZ +AmZuyIF+mQC/cgojIsrBMzBxb1kKqzATF4+XwPwgKz7fmiddmHyYz2WDJfAjIveJ +ZjdMjM4+EytGlkkJ52T8V8ds0/L2qKexJ+NBLxkeQLfV8n1mIk7zX7jguwbCG1Pr +nEMdJ3Sew20vnje+RsngAzdPChoJpVsWi/K7cettX/tbnre1DL02GXc5qJoQYk7b +3zkmhz31TgFrd9VVtmUGyFXAysuSAb3EN+5VnHGr0xKkeg8utErea2FNtNIgua8H +ONfm9Eiyaav1SVKzPHlyqLtcdxH3I8Wg7yqMsaprZ1n5A1v/levxnL8+It02KseD +5HqV4rf/cImSlCt3lpRg8U5E1pyFQ2IVEC/XTDMiI3c+AR+w2jSRB3Bwn9zJtFlW +KHG3m1xGI4ck+Lci1JvWWLXQagQSPtZTsubxTQNx1gsgZhgv1JHVZMdbVlAbbRMC +1nSuJNl7KPAS/VfzAgEDAoIBgHRXxaynbVP5gkO0ug6Qw/E27wzIw4SmjsxG6Wpe +K7kfDeRskKxESdsA/xCrKkwGwhcx1iIgS5+Qscd1Yg+1D9X9asd/P7waPmWoZd+Z +AhlKwhdPsO7PiF3e1AzHhGQwsUTt/Y/aSI1MpHBvy2/s1h9mFCslOUxTmWw0oj/Q +ldIEgWeNR72CE2+jFIJIyml6ftnb6qzPiga8Bm48ubKh0kvySOqnkmnPzgh+JBD6 +JnBmtZbfPT97bwTT+N6rnPqOOApvfHPf15kWI8yDbprG1l4OCUaIUH1AszxLd826 +5IPM+8gINLRDP1MA6azECPjTyHXhtnSIBZCyWSVkc05vYmNXYUNiXWMajcxW9M02 +wKzFELO8NCEAkaTPxwo4SCyIjUxiK1LbQ9h8PSy4c1+gGP4LAMR8xqP4QKg6zdu9 +osUGG/xRe/uufgTBFkcjqBHtK5L5VI0jeNIUAgW/6iNbYXjBMJ0GfauLs+g1VsOm +WfdgXzsb9DYdMa0OXXHypmV4GwKBwQDUwQj8RKJ6c8cT4vcWCoJvJF00+RFL+P3i +Gx2DLERxRrDa8AVGfqaCjsR+3vLgG8V/py+z+dxZYSqeB80Qeo6PDITcRKoeAYh9 +xlT3LJOS+k1cJcEmlbbO2IjLkTmzSwa80fWexKu8/Xv6vv15gpqYl1ngYoqJM3pd +vzmTIOi7MKSZ0WmEQavrZj8zK4endE3v0eAEeQ55j1GImbypSf7Idh7wOXtjZ7WD +Dg6yWDrri+AP/L3gClMj8wsAxMV4ZR8CgcEA0fzDHkFa6raVOxWnObmRoDhAtE0a +cjUj976NM5yyfdf2MrKy4/RhdTiPZ6b08/lBC/+xRfV3xKVGzacm6QjqjZrUpgHC +0LKiZaMtccCJjLtPwQd0jGQEnKfMFaPsnhOc5y8qVkCzVOSthY5qhz0XNotHHFmJ +gffVgB0iqrMTvSL7IA2yqqpOqNRlhaYhNl8TiFP3gIeMtVa9rZy31JPgT2uJ+kfo +gV7sdTPEjPWZd7OshGxWpT6QfVDj/T9T7L6tAoHBAI3WBf2DFvxNL2KXT2QHAZ9t +k3imC4f7U+wSE6zILaDZyzygA4RUbwG0gv8/TJVn2P/Eynf76DuWHGlaiLWnCbSz +Az2DHBQBBaku409zDQym3j1ugMRjzzSQWzJg0SIyBH3hTmnYcn3+Uqcp/lEBvGW6 +O+rsXFt3pukqJmIV8HzLGGaLm62BHUeZf3dyWm+i3p/hQAL7Xvu04QW70xuGqdr5 +afV7p5eaeQIJXyGQJ0eylV/90+qxjMKiB1XYg6WYvwKBwQCL/ddpgOdHJGN8uRom +e7Zq0Csi3hGheMKlKbN3vcxT5U7MdyHtTZZOJbTvxKNNUNYH/8uD+PqDGNneb29G +BfGzvI3EASyLIcGZF3OhKwZd0jUrWk2y7Vhob91jwp2+t73vdMbkKyI4mHOuXvGv +fg95si9oO7EBT+Oqvhccd2J+F1IVXncccYnF4u5ZGWt5lLewN/pVr7MjjykeaHqN +t+rfnQam2psA6fL4zS2zTmZPzR2tnY8Y1GBTi0Ko1OKd1HMCgcAb5cB/7/AQlhP9 +yQa04PLH9ygQkKKptZp7dy5WcWRx0K/hAHRoi2aw1wZqfm7VBNu2SLcs90kCCCxp +6C5sfJi6b8NpNbIPC+sc9wsFr7pGo9SFzQ78UlcWYK2Gu2FxlMjonhka5hvo4zvg +WxlpXKEkaFt3gLd92m/dMqBrHfafH7VwOJY2zT3WIpjwuk0ZzmRg5p0pG/svVQEH +NZmwRwlopysbR69B/n1nefJ84UO50fLh5s5Zr3gBRwbWNZyzhXk= +-----END RSA PRIVATE KEY----- diff --git a/samplecode/protobuf/enclave/Makefile b/samplecode/protobuf/enclave/Makefile new file mode 100644 index 000000000..7d6c5f7ab --- /dev/null +++ b/samplecode/protobuf/enclave/Makefile @@ -0,0 +1,43 @@ +# Copyright (C) 2017-2018 Baidu, Inc. All Rights Reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Baidu, Inc., nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +Rust_Enclave_Name := libenclave.a +Rust_Enclave_Files := $(wildcard src/*.rs) + +.PHONY: all + +all: $(Rust_Enclave_Name) + +$(Rust_Enclave_Name): $(Rust_Enclave_Files) +ifeq ($(XARGO_SGX), 1) + xargo build --target x86_64-unknown-linux-sgx --release + cp ./target/x86_64-unknown-linux-sgx/release/libhelloworldsampleenclave.a ../lib/libenclave.a +else + cargo build --release + cp ./target/release/libhelloworldsampleenclave.a ../lib/libenclave.a +endif \ No newline at end of file diff --git a/samplecode/protobuf/enclave/Xargo.toml b/samplecode/protobuf/enclave/Xargo.toml new file mode 100644 index 000000000..84570601e --- /dev/null +++ b/samplecode/protobuf/enclave/Xargo.toml @@ -0,0 +1,25 @@ +[dependencies] +alloc = {} +panic_unwind = {} +panic_abort = {} + +[dependencies.compiler_builtins] +features = ["c", "compiler-builtins"] +git = "https://github.com/rust-lang-nursery/compiler-builtins" +stage = 1 + +[dependencies.std] +path = "../../../xargo/sgx_tstd" +stage = 2 + +[dependencies.sgx_rand] +path = "../../../xargo/sgx_rand" +stage = 3 + +[dependencies.sgx_serialize] +path = "../../../xargo/sgx_serialize" +stage = 3 + +[dependencies.sgx_tunittest] +path = "../../../xargo/sgx_tunittest" +stage = 3 \ No newline at end of file diff --git a/samplecode/protobuf/enclave/src/lib.rs b/samplecode/protobuf/enclave/src/lib.rs new file mode 100644 index 000000000..4160e82d7 --- /dev/null +++ b/samplecode/protobuf/enclave/src/lib.rs @@ -0,0 +1,63 @@ +// Copyright (C) 2017-2018 Baidu, Inc. All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in +// the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Baidu, Inc., nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#![crate_name = "helloworldsampleenclave"] +#![crate_type = "staticlib"] + +#![cfg_attr(not(target_env = "sgx"), no_std)] +#![cfg_attr(target_env = "sgx", feature(rustc_private))] + +extern crate sgx_types; +#[cfg(not(target_env = "sgx"))] +#[macro_use] +extern crate sgx_tstd as std; + +use sgx_types::*; +use std::string::String; +use std::io::{self, Write}; +use std::slice; + +extern crate protobuf; +mod person; +use person::Person; +use protobuf::hex::decode_hex; +use protobuf::parse_from_bytes; + +#[no_mangle] +pub extern "C" fn say_something(some_string: *const u8, some_len: usize) -> sgx_status_t { + + let str_slice = unsafe { slice::from_raw_parts(some_string, some_len) }; + let _ = io::stdout().write(str_slice); + + let decoded = decode_hex(&String::from_utf8(str_slice.to_vec()).unwrap()); + let parsed = parse_from_bytes::(&decoded).unwrap(); + + println!("\nname: {}, id: 0x{:08X}, email at: {}", parsed.get_name(), parsed.get_id(), parsed.get_email() ); + + sgx_status_t::SGX_SUCCESS +} diff --git a/samplecode/protobuf/enclave/x86_64-unknown-linux-sgx.json b/samplecode/protobuf/enclave/x86_64-unknown-linux-sgx.json new file mode 100644 index 000000000..6cbb524f4 --- /dev/null +++ b/samplecode/protobuf/enclave/x86_64-unknown-linux-sgx.json @@ -0,0 +1,31 @@ +{ + "arch": "x86_64", + "cpu": "x86-64", + "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", + "dynamic-linking": true, + "env": "sgx", + "exe-allocation-crate": "alloc_system", + "executables": true, + "has-elf-tls": true, + "has-rpath": true, + "linker-flavor": "gcc", + "linker-is-gnu": true, + "llvm-target": "x86_64-unknown-linux-gnu", + "max-atomic-width": 64, + "os": "linux", + "position-independent-executables": true, + "pre-link-args": { + "gcc": [ + "-Wl,--as-needed", + "-Wl,-z,noexecstack", + "-m64" + ] + }, + "relro-level": "full", + "stack-probes": true, + "target-c-int-width": "32", + "target-endian": "little", + "target-family": "unix", + "target-pointer-width": "64", + "vendor": "unknown" +} diff --git a/samplecode/protobuf/lib/readme.txt b/samplecode/protobuf/lib/readme.txt new file mode 100644 index 000000000..7951405f8 --- /dev/null +++ b/samplecode/protobuf/lib/readme.txt @@ -0,0 +1 @@ +lib \ No newline at end of file diff --git a/samplecode/protobuf/person.proto b/samplecode/protobuf/person.proto new file mode 100644 index 000000000..fdab9e978 --- /dev/null +++ b/samplecode/protobuf/person.proto @@ -0,0 +1,5 @@ +message Person { + required string name = 1; + required int32 id = 2; + optional string email = 3; +} diff --git a/samplecode/test_all.sh b/samplecode/test_all.sh index d42a84daf..499d73edc 100755 --- a/samplecode/test_all.sh +++ b/samplecode/test_all.sh @@ -36,6 +36,7 @@ test_cases=(backtrace \ # hugemem \ localattestation \ machine-learning \ + protobuf \ sealeddata \ serialize \ thread \ diff --git a/third_party/protobuf/Cargo.toml b/third_party/protobuf/Cargo.toml new file mode 100644 index 000000000..213bb784a --- /dev/null +++ b/third_party/protobuf/Cargo.toml @@ -0,0 +1,44 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# 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 +# +# 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) + +[package] +name = "protobuf" +version = "1.4.4" +authors = ["Stepan Koltsov "] +description = "Rust implementation of Google protocol buffers\n" +homepage = "https://github.com/stepancheg/rust-protobuf/" +documentation = "https://github.com/stepancheg/rust-protobuf/blob/master/README.md" +license = "MIT/Apache-2.0" +repository = "https://github.com/stepancheg/rust-protobuf/" + +[lib] +doctest = false + +#[[bin]] +#name = "protoc-gen-rust" +#path = "protoc-gen-rust.rs" +#test = false +# +#[[bin]] +#name = "protobuf-bin-gen-rust-do-not-use" +#path = "protobuf-bin-gen-rust-do-not-use.rs" +#test = false + +[dependencies.bytes] +version = "0.*" +optional = true + +[target.'cfg(not(target_env = "sgx"))'.dependencies] +sgx_tstd = { path = "../../sgx_tstd" } + +[features] +with-bytes = ["bytes"] diff --git a/third_party/protobuf/Cargo.toml.orig b/third_party/protobuf/Cargo.toml.orig new file mode 100644 index 000000000..c4ef505d6 --- /dev/null +++ b/third_party/protobuf/Cargo.toml.orig @@ -0,0 +1,33 @@ +[package] + +name = "protobuf" +version = "1.4.4" +authors = ["Stepan Koltsov "] +license = "MIT/Apache-2.0" +homepage = "https://github.com/stepancheg/rust-protobuf/" +repository = "https://github.com/stepancheg/rust-protobuf/" +documentation = "https://github.com/stepancheg/rust-protobuf/blob/master/README.md" +description = """ +Rust implementation of Google protocol buffers +""" + +[lib] +doctest = false + +[features] +with-bytes = ["bytes"] + +[dependencies] +bytes = { version = "0.*", optional = true } + +[[bin]] + +name = "protoc-gen-rust" +path = "protoc-gen-rust.rs" +test = false + +[[bin]] + +name = "protobuf-bin-gen-rust-do-not-use" +path = "protobuf-bin-gen-rust-do-not-use.rs" +test = false diff --git a/third_party/protobuf/README.md b/third_party/protobuf/README.md new file mode 100644 index 000000000..6e9960058 --- /dev/null +++ b/third_party/protobuf/README.md @@ -0,0 +1,28 @@ +## How to develop rust-protobuf itself + +### ./build.sh + +Compile the project. + +### ./regenerate.sh + +Generate .rs files from .proto files, that needed +internally in rust-protobuf. + +### rust test lib/protobuf.rs + +Execute the test suite. + +### ./full-rebuild.sh + +* build project +* regenerate .rs files +* build project again to ensure that generated files are correct +* run tests + +This is primary script for development. + +### ./checkout-generated.sh + +Revert generated files to git version. Use if generated +files are incorrect. diff --git a/third_party/protobuf/Xargo.toml b/third_party/protobuf/Xargo.toml new file mode 100644 index 000000000..ab88033e8 --- /dev/null +++ b/third_party/protobuf/Xargo.toml @@ -0,0 +1,14 @@ +[dependencies] +alloc = {} +panic_unwind = {} +panic_abort = {} + +[dependencies.compiler_builtins] +features = ["c", "compiler-builtins"] +git = "https://github.com/rust-lang-nursery/compiler-builtins" +stage = 1 + +[dependencies.std] +path = "../../xargo/sgx_tstd" +stage = 2 + diff --git a/third_party/protobuf/benches/coded_input_stream.rs b/third_party/protobuf/benches/coded_input_stream.rs new file mode 100644 index 000000000..2abed8e41 --- /dev/null +++ b/third_party/protobuf/benches/coded_input_stream.rs @@ -0,0 +1,102 @@ +#![feature(test)] + +extern crate test; +extern crate protobuf; + +use std::io; +use std::io::Read; + +use protobuf::stream::CodedInputStream; + +use self::test::Bencher; + +fn make_bytes(len: usize) -> Vec { + let mut r = Vec::with_capacity(len); + for i in 0..len { + r.push((i % 10) as u8); + } + test::black_box(r) +} + +#[bench] +fn read_byte(b: &mut Bencher) { + let v = make_bytes(1_000); + b.iter(|| { + let mut is = CodedInputStream::from_bytes(test::black_box(&v)); + while !is.eof().expect("eof") { + test::black_box(is.read_raw_byte().expect("read")); + } + }); +} + +#[bench] +fn read_byte_no_eof(b: &mut Bencher) { + let v = make_bytes(1_000); + b.iter(|| { + let mut is = CodedInputStream::from_bytes(test::black_box(&v)); + for _ in 0..v.len() { + test::black_box(is.read_raw_byte().expect("read")); + } + assert!(is.eof().expect("eof")); + }); +} + +#[bench] +fn read_byte_from_vec(b: &mut Bencher) { + let v = make_bytes(1_000); + b.iter(|| { + let mut v = io::Cursor::new(test::black_box(&v)); + loop { + let mut buf = [0]; + let count = v.read(&mut buf).expect("read"); + if count == 0 { + break; + } + test::black_box(buf); + } + }); +} + +#[bench] +fn read_varint_12(b: &mut Bencher) { + let mut v = Vec::new(); + { + let mut v = protobuf::CodedOutputStream::vec(&mut v); + for i in 0..1000 { + // one or two byte varints + v.write_raw_varint32((i * 7919) % (1 << 14)).expect("write"); + } + v.flush().expect("flush"); + } + b.iter(|| { + let mut is = CodedInputStream::from_bytes(test::black_box(&v)); + let mut count = 0; + while !is.eof().expect("eof") { + test::black_box(is.read_raw_varint32().expect("read")); + count += 1; + } + assert_eq!(1000, count); + }) +} + +#[bench] +fn read_varint_1(b: &mut Bencher) { + let mut v = Vec::new(); + { + let mut v = protobuf::CodedOutputStream::vec(&mut v); + for i in 0..1000 { + // one or two byte varints + v.write_raw_varint32((i * 7919) % (1 << 7)).expect("write"); + } + v.flush().expect("flush"); + } + b.iter(|| { + let mut is = CodedInputStream::from_bytes(test::black_box(&v)); + let mut count = 0; + while !is.eof().expect("eof") { + test::black_box(is.read_raw_varint32().expect("read")); + count += 1; + } + assert_eq!(1000, count); + }) +} diff --git a/third_party/protobuf/benches/coded_output_stream.rs b/third_party/protobuf/benches/coded_output_stream.rs new file mode 100644 index 000000000..c7feba656 --- /dev/null +++ b/third_party/protobuf/benches/coded_output_stream.rs @@ -0,0 +1,48 @@ +#![feature(test)] + +extern crate test; +extern crate protobuf; + +use protobuf::stream; + +use self::test::Bencher; + +#[inline] +fn buffer_write_byte(os: &mut stream::CodedOutputStream) { + for i in 0..10 { + os.write_raw_byte(test::black_box(i as u8)).unwrap(); + } + os.flush().unwrap(); +} + +#[inline] +fn buffer_write_bytes(os: &mut stream::CodedOutputStream) { + for _ in 0..10 { + os.write_raw_bytes(test::black_box(b"1234567890")).unwrap(); + } + os.flush().unwrap(); +} + +#[bench] +fn bench_buffer(b: &mut Bencher) { + b.iter(|| { + let mut v = Vec::new(); + { + let mut os = stream::CodedOutputStream::new(&mut v); + buffer_write_byte(&mut os); + } + v + }); +} + +#[bench] +fn bench_buffer_bytes(b: &mut Bencher) { + b.iter(|| { + let mut v = Vec::new(); + { + let mut os = stream::CodedOutputStream::new(&mut v); + buffer_write_bytes(&mut os); + } + v + }); +} diff --git a/third_party/protobuf/build.sh b/third_party/protobuf/build.sh new file mode 100755 index 000000000..363348c64 --- /dev/null +++ b/third_party/protobuf/build.sh @@ -0,0 +1,8 @@ +#!/bin/sh -ex + +# Test should be executed before build. +# See https://github.com/rust-lang/cargo/issues/961 +cargo test --features=$RUST_PROTOBUF_FEATURES +cargo build --features=$RUST_PROTOBUF_FEATURES + +# vim: set ts=4 sw=4 et: diff --git a/third_party/protobuf/full-rebuild.sh b/third_party/protobuf/full-rebuild.sh new file mode 100755 index 000000000..dabf29945 --- /dev/null +++ b/third_party/protobuf/full-rebuild.sh @@ -0,0 +1,31 @@ +#!/bin/sh -ex + +die() { + echo "$@" >&2 + exit 1 +} + +cd $(dirname $0) + +# Build protoc-gen-rust +./build.sh + +protoc_ver=$(protoc --version) +case "$protoc_ver" in + "libprotoc 3"*) + # Generate from descriptor.proto + ./regenerate.sh + # Build again with regenerated descriptor.proto + ./build.sh + ;; + "libprotoc 2"*) + echo "do not regenerate with proto 2" + ;; + *) + die "unknown protoc version" + ;; +esac + +./../protobuf-test/test.sh + +# vim: set ts=4 sw=4 et: diff --git a/third_party/protobuf/protobuf-bin-gen-rust-do-not-use.rs b/third_party/protobuf/protobuf-bin-gen-rust-do-not-use.rs new file mode 100644 index 000000000..28ad61cd9 --- /dev/null +++ b/third_party/protobuf/protobuf-bin-gen-rust-do-not-use.rs @@ -0,0 +1,36 @@ +extern crate protobuf; + +use std::fs::*; +use std::io::Read; +use std::io::Write; +use std::path::Path; + +use protobuf::parse_from_reader; +use protobuf::descriptor::*; +use protobuf::codegen::*; + + +fn write_file(bin: &str) { + let mut is = File::open(&Path::new(bin)).unwrap(); + let fds = parse_from_reader::(&mut is as &mut Read).unwrap(); + + let file_names: Vec = fds.get_file() + .iter() + .map(|f| f.get_name().to_string()) + .collect(); + let results = gen(fds.get_file(), &file_names); + + for r in &results { + let mut file_writer = File::create(&Path::new(&r.name)).unwrap(); + file_writer.write(&r.content).unwrap(); + } +} + +fn main() { + let args: Vec = std::env::args().collect(); + if args.len() != 2 { + panic!("must have exactly one argument"); + } + let ref pb_bin = args[1]; + write_file(&pb_bin); +} diff --git a/third_party/protobuf/protoc-gen-rust.rs b/third_party/protobuf/protoc-gen-rust.rs new file mode 100644 index 000000000..f6486630b --- /dev/null +++ b/third_party/protobuf/protoc-gen-rust.rs @@ -0,0 +1,8 @@ +extern crate protobuf; + +use protobuf::codegen; + + +fn main() { + codegen::protoc_gen_rust_main(); +} diff --git a/third_party/protobuf/regenerate.sh b/third_party/protobuf/regenerate.sh new file mode 100755 index 000000000..b95003d2d --- /dev/null +++ b/third_party/protobuf/regenerate.sh @@ -0,0 +1,49 @@ +#!/bin/sh -ex + +cd $(dirname $0) + +die() { + echo "$@" >&2 + exit 1 +} + +protoc_ver=$(protoc --version) +case "$protoc_ver" in + "libprotoc 3"*) ;; + *) + die "you need to use protobuf 3 to regenerate .rs from .proto" + ;; +esac + +where_am_i=$(cd `dirname $0`/..; pwd) +PATH="$where_am_i/target/debug:$PATH" + +rm -rf tmp-generated +mkdir tmp-generated + +protoc --rust_out tmp-generated -I../proto \ + ../proto/google/protobuf/*.proto \ + ../proto/google/protobuf/compiler/* \ + ../proto/rustproto.proto + +mv tmp-generated/descriptor.rs tmp-generated/plugin.rs tmp-generated/rustproto.rs src/ +mv tmp-generated/*.rs src/well_known_types/ +( + cd src/well_known_types + exec > mod.rs + echo "// This file is generated. Do not edit" + + mod_list() { + ls | grep -v mod.rs | sed -e 's,\.rs$,,' + } + + echo + mod_list | sed -e 's,^,mod ,; s,$,;,' + + echo + mod_list | while read mod; do + echo "pub use self::$mod::*;" + done +) + +# vim: set ts=4 sw=4 et: diff --git a/third_party/protobuf/src/buf_read_iter.rs b/third_party/protobuf/src/buf_read_iter.rs new file mode 100644 index 000000000..df0f283be --- /dev/null +++ b/third_party/protobuf/src/buf_read_iter.rs @@ -0,0 +1,436 @@ +use std::cmp; +use std::io::Read; +use std::io::BufRead; +use std::io::BufReader; +use std::mem; +use std::u64; + +#[cfg(feature = "bytes")] +use bytes::Bytes; +#[cfg(feature = "bytes")] +use bytes::BytesMut; +#[cfg(feature = "bytes")] +use bytes::BufMut; + +use ProtobufResult; +use ProtobufError; +use error::WireError; + + +// If an input stream is constructed with a `Read`, we create a +// `BufReader` with an internal buffer of this size. +const INPUT_STREAM_BUFFER_SIZE: usize = 4096; + +const USE_UNSAFE_FOR_SPEED: bool = true; + +const NO_LIMIT: u64 = u64::MAX; + + +/// Hold all possible combinations of input source +enum InputSource<'a> { + BufRead(&'a mut BufRead), + Read(BufReader<&'a mut Read>), + Slice(&'a [u8]), + #[cfg(feature = "bytes")] + Bytes(&'a Bytes), +} + +/// Dangerous implementation of `BufRead`. +/// +/// Unsafe wrapper around BufRead which assumes that `BufRead` buf is +/// not moved when `BufRead` is moved. +/// +/// This assumption is generally incorrect, however, in practice +/// `BufReadIter` is created either from `BufRead` reference (which +/// cannot be moved, because it is locked by `CodedInputStream`) or from +/// `BufReader` which does not move its buffer (we know that from +/// inspecting rust standard library). +/// +/// It is important for `CodedInputStream` performance that small reads +/// (e. g. 4 bytes reads) do not involve virtual calls or switches. +/// This is achievable with `BufReadIter`. +pub struct BufReadIter<'a> { + input_source: InputSource<'a>, + buf: &'a [u8], + pos_within_buf: usize, + limit_within_buf: usize, + pos_of_buf_start: u64, + limit: u64, +} + +impl<'a> Drop for BufReadIter<'a> { + fn drop(&mut self) { + match self.input_source { + InputSource::BufRead(ref mut buf_read) => buf_read.consume(self.pos_within_buf), + InputSource::Read(_) => { + // Nothing to flush, because we own BufReader + } + _ => {} + } + } +} + +impl<'ignore> BufReadIter<'ignore> { + pub fn from_read<'a>(read: &'a mut Read) -> BufReadIter<'a> { + BufReadIter { + input_source: InputSource::Read( + BufReader::with_capacity(INPUT_STREAM_BUFFER_SIZE, read), + ), + buf: &[], + pos_within_buf: 0, + limit_within_buf: 0, + pos_of_buf_start: 0, + limit: NO_LIMIT, + } + } + + pub fn from_buf_read<'a>(buf_read: &'a mut BufRead) -> BufReadIter<'a> { + BufReadIter { + input_source: InputSource::BufRead(buf_read), + buf: &[], + pos_within_buf: 0, + limit_within_buf: 0, + pos_of_buf_start: 0, + limit: NO_LIMIT, + } + } + + pub fn from_byte_slice<'a>(bytes: &'a [u8]) -> BufReadIter<'a> { + BufReadIter { + input_source: InputSource::Slice(bytes), + buf: bytes, + pos_within_buf: 0, + limit_within_buf: bytes.len(), + pos_of_buf_start: 0, + limit: NO_LIMIT, + } + } + + #[cfg(feature = "bytes")] + pub fn from_bytes<'a>(bytes: &'a Bytes) -> BufReadIter<'a> { + BufReadIter { + input_source: InputSource::Bytes(bytes), + buf: &bytes, + pos_within_buf: 0, + limit_within_buf: bytes.len(), + pos_of_buf_start: 0, + limit: NO_LIMIT, + } + } + + #[inline] + fn assertions(&self) { + debug_assert!(self.pos_within_buf <= self.limit_within_buf); + debug_assert!(self.limit_within_buf <= self.buf.len()); + debug_assert!(self.pos_of_buf_start + self.pos_within_buf as u64 <= self.limit); + } + + #[inline(always)] + pub fn pos(&self) -> u64 { + self.pos_of_buf_start + self.pos_within_buf as u64 + } + + /// Recompute `limit_within_buf` after update of `limit` + #[inline] + fn update_limit_within_buf(&mut self) { + if self.pos_of_buf_start + (self.buf.len() as u64) <= self.limit { + self.limit_within_buf = self.buf.len(); + } else { + self.limit_within_buf = (self.limit - self.pos_of_buf_start) as usize; + } + + self.assertions(); + } + + pub fn push_limit(&mut self, limit: u64) -> ProtobufResult { + // TODO: return error instead of panic + let new_limit = match self.pos().checked_add(limit) { + Some(new_limit) => new_limit, + None => return Err(ProtobufError::WireError(WireError::Other)), + }; + + if new_limit > self.limit { + return Err(ProtobufError::WireError(WireError::Other)); + } + + let prev_limit = mem::replace(&mut self.limit, new_limit); + + self.update_limit_within_buf(); + + Ok(prev_limit) + } + + #[inline] + pub fn pop_limit(&mut self, limit: u64) { + assert!(limit >= self.limit); + + self.limit = limit; + + self.update_limit_within_buf(); + } + + #[inline] + pub fn remaining_in_buf(&self) -> &[u8] { + if USE_UNSAFE_FOR_SPEED { + unsafe { + &self.buf + .get_unchecked(self.pos_within_buf..self.limit_within_buf) + } + } else { + &self.buf[self.pos_within_buf..self.limit_within_buf] + } + } + + #[inline(always)] + pub fn remaining_in_buf_len(&self) -> usize { + self.limit_within_buf - self.pos_within_buf + } + + pub fn bytes_until_limit(&self) -> u64 { + if self.limit == NO_LIMIT { + NO_LIMIT + } else { + self.limit - (self.pos_of_buf_start + self.pos_within_buf as u64) + } + } + + #[inline(always)] + pub fn eof(&mut self) -> ProtobufResult { + if self.pos_within_buf == self.limit_within_buf { + Ok(self.fill_buf()?.is_empty()) + } else { + Ok(false) + } + } + + #[inline(always)] + pub fn read_byte(&mut self) -> ProtobufResult { + if self.pos_within_buf == self.limit_within_buf { + self.do_fill_buf()?; + if self.remaining_in_buf_len() == 0 { + return Err(ProtobufError::WireError(WireError::UnexpectedEof)); + } + } + + let r = if USE_UNSAFE_FOR_SPEED { + unsafe { *self.buf.get_unchecked(self.pos_within_buf) } + } else { + self.buf[self.pos_within_buf] + }; + self.pos_within_buf += 1; + Ok(r) + } + + #[cfg(feature = "bytes")] + pub fn read_exact_bytes(&mut self, len: usize) -> ProtobufResult { + if let InputSource::Bytes(bytes) = self.input_source { + if self.pos_within_buf + len > self.limit_within_buf { + return Err(ProtobufError::WireError(WireError::UnexpectedEof)); + } + let r = bytes.slice(self.pos_within_buf, self.pos_within_buf + len); + self.pos_within_buf += len; + Ok(r) + } else { + let mut r = BytesMut::with_capacity(len); + unsafe { + { + let mut buf = &mut r.bytes_mut()[..len]; + self.read_exact(buf)?; + } + r.advance_mut(len); + } + Ok(r.freeze()) + } + } + + fn _read(&mut self, buf: &mut [u8]) -> ProtobufResult { + self.fill_buf()?; + + let rem = &self.buf[self.pos_within_buf..self.limit_within_buf]; + + let len = cmp::min(rem.len(), buf.len()); + &mut buf[..len].copy_from_slice(&rem[..len]); + self.pos_within_buf += len; + Ok(len) + } + + pub fn read_exact(&mut self, buf: &mut [u8]) -> ProtobufResult<()> { + if self.remaining_in_buf_len() >= buf.len() { + let buf_len = buf.len(); + buf.copy_from_slice( + &self.buf[self.pos_within_buf..self.pos_within_buf + buf_len], + ); + self.pos_within_buf += buf_len; + return Ok(()); + } + + if self.bytes_until_limit() < buf.len() as u64 { + return Err(ProtobufError::WireError(WireError::UnexpectedEof)); + } + + let consume = self.pos_within_buf; + self.pos_of_buf_start += self.pos_within_buf as u64; + self.pos_within_buf = 0; + self.buf = &[]; + self.limit_within_buf = 0; + + match self.input_source { + InputSource::Read(ref mut buf_read) => { + buf_read.consume(consume); + buf_read.read_exact(buf)?; + } + InputSource::BufRead(ref mut buf_read) => { + buf_read.consume(consume); + buf_read.read_exact(buf)?; + } + _ => { + return Err(ProtobufError::WireError(WireError::UnexpectedEof)); + } + } + + self.pos_of_buf_start += buf.len() as u64; + + self.assertions(); + + Ok(()) + } + + fn do_fill_buf(&mut self) -> ProtobufResult<()> { + debug_assert!(self.pos_within_buf == self.limit_within_buf); + + // Limit is reached, do not fill buf, because otherwise + // synchronous read from `CodedInputStream` may block. + if self.limit == self.pos() { + return Ok(()); + } + + let consume = self.buf.len(); + self.pos_of_buf_start += self.buf.len() as u64; + self.buf = &[]; + self.pos_within_buf = 0; + self.limit_within_buf = 0; + + match self.input_source { + InputSource::Read(ref mut buf_read) => { + buf_read.consume(consume); + self.buf = unsafe { mem::transmute(buf_read.fill_buf()?) }; + } + InputSource::BufRead(ref mut buf_read) => { + buf_read.consume(consume); + self.buf = unsafe { mem::transmute(buf_read.fill_buf()?) }; + } + _ => { + return Ok(()); + } + } + + self.update_limit_within_buf(); + + Ok(()) + } + + #[inline(always)] + pub fn fill_buf(&mut self) -> ProtobufResult<&[u8]> { + if self.pos_within_buf == self.limit_within_buf { + self.do_fill_buf()?; + } + + Ok(if USE_UNSAFE_FOR_SPEED { + unsafe { + self.buf + .get_unchecked(self.pos_within_buf..self.limit_within_buf) + } + } else { + &self.buf[self.pos_within_buf..self.limit_within_buf] + }) + } + + #[inline(always)] + pub fn consume(&mut self, amt: usize) { + assert!(amt <= self.limit_within_buf - self.pos_within_buf); + self.pos_within_buf += amt; + } +} + +#[cfg(all(test, feature = "bytes"))] +mod test_bytes { + use super::*; + use std::io::Write; + + fn make_long_string(len: usize) -> Vec { + let mut s = Vec::new(); + while s.len() < len { + let len = s.len(); + write!(&mut s, "{}", len).expect("unexpected"); + } + s.truncate(len); + s + } + + #[test] + fn read_exact_bytes_from_slice() { + let bytes = make_long_string(100); + let mut bri = BufReadIter::from_byte_slice(&bytes[..]); + assert_eq!(&bytes[..90], &bri.read_exact_bytes(90).unwrap()[..]); + assert_eq!(bytes[90], bri.read_byte().expect("read_byte")); + } + + #[test] + fn read_exact_bytes_from_bytes() { + let bytes = Bytes::from(make_long_string(100)); + let mut bri = BufReadIter::from_bytes(&bytes); + let read = bri.read_exact_bytes(90).unwrap(); + assert_eq!(&bytes[..90], &read[..]); + assert_eq!(&bytes[..90].as_ptr(), &read.as_ptr()); + assert_eq!(bytes[90], bri.read_byte().expect("read_byte")); + } + +} + +#[cfg(test)] +mod test { + use super::*; + use std::io::BufRead; + use std::io::Read; + use std::io; + + #[test] + fn eof_at_limit() { + struct Read5ThenPanic { + pos: usize, + } + + impl Read for Read5ThenPanic { + fn read(&mut self, _buf: &mut [u8]) -> io::Result { + unreachable!(); + } + } + + impl BufRead for Read5ThenPanic { + fn fill_buf(&mut self) -> io::Result<&[u8]> { + assert_eq!(0, self.pos); + static ZERO_TO_FIVE: &'static [u8] = &[0, 1, 2, 3, 4]; + Ok(ZERO_TO_FIVE) + } + + fn consume(&mut self, amt: usize) { + if amt == 0 { + // drop of BufReadIter + return; + } + + assert_eq!(0, self.pos); + assert_eq!(5, amt); + self.pos += amt; + } + } + + let mut read = Read5ThenPanic { pos : 0 }; + let mut buf_read_iter = BufReadIter::from_buf_read(&mut read); + assert_eq!(0, buf_read_iter.pos()); + let _prev_limit = buf_read_iter.push_limit(5); + buf_read_iter.read_byte().expect("read_byte"); + buf_read_iter.read_exact(&mut [1, 2, 3, 4]).expect("read_exact"); + assert!(buf_read_iter.eof().expect("eof")); + } +} diff --git a/third_party/protobuf/src/cached_size.rs b/third_party/protobuf/src/cached_size.rs new file mode 100644 index 000000000..33af34545 --- /dev/null +++ b/third_party/protobuf/src/cached_size.rs @@ -0,0 +1,25 @@ +/// Cached size field used in generated code. +/// It is always equal to itself to simplify generated code. +/// (Generated code can use `#[derive(Eq)]`). +#[derive(Debug, Default, Clone)] +pub struct CachedSize { + size: ::std::cell::Cell, +} + +impl CachedSize { + pub fn get(&self) -> u32 { + self.size.get() + } + + pub fn set(&self, size: u32) { + self.size.set(size) + } +} + +impl PartialEq for CachedSize { + fn eq(&self, _other: &CachedSize) -> bool { + true + } +} + +impl Eq for CachedSize {} diff --git a/third_party/protobuf/src/chars.rs b/third_party/protobuf/src/chars.rs new file mode 100644 index 000000000..1c15cf2b9 --- /dev/null +++ b/third_party/protobuf/src/chars.rs @@ -0,0 +1,96 @@ +use std::str; +use std::ops::Deref; +use std::fmt; + +use bytes::Bytes; + +use clear::Clear; + +/// Thin wrapper around `Bytes` which guarantees that bytes are valid UTF-8 string. +#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub struct Chars(Bytes); + +impl Chars { + /// New empty object. + pub fn new() -> Chars { + Chars(Bytes::new()) + } + + /// Try convert from `Bytes` + pub fn from_bytes(bytes: Bytes) -> Result { + str::from_utf8(&bytes)?; + + Ok(Chars(bytes)) + } + + /// Len in bytes. + pub fn len(&self) -> usize { + self.0.len() + } + + pub fn is_empty(&self) -> bool { + self.0.is_empty() + } +} + +impl<'a> From<&'a str> for Chars { + fn from(src: &'a str) -> Chars { + Chars(Bytes::from(src)) + } +} + +impl From for Chars { + fn from(src: String) -> Chars { + Chars(Bytes::from(src)) + } +} + +impl Default for Chars { + fn default() -> Self { + Chars::new() + } +} + +impl Deref for Chars { + type Target = str; + + fn deref(&self) -> &str { + unsafe { str::from_utf8_unchecked(&self.0) } + } +} + +impl Clear for Chars { + fn clear(&mut self) { + self.0.clear(); + } +} + +impl fmt::Display for Chars { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&**self, f) + } +} + +impl fmt::Debug for Chars { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&**self, f) + } +} + + +#[cfg(test)] +mod test { + use super::Chars; + + #[test] + fn test_display_and_debug() { + let s = "test"; + let string: String = s.into(); + let chars: Chars = s.into(); + + assert_eq!(format!("{}", string), format!("{}", chars)); + assert_eq!(format!("{:?}", string), format!("{:?}", chars)); + } +} diff --git a/third_party/protobuf/src/clear.rs b/third_party/protobuf/src/clear.rs new file mode 100644 index 000000000..c1746d1ec --- /dev/null +++ b/third_party/protobuf/src/clear.rs @@ -0,0 +1,35 @@ +use std::string::String; +use std::vec::Vec; + +#[cfg(feature = "bytes")] +use bytes::Bytes; + +/// anything that can be cleared +pub trait Clear { + fn clear(&mut self); +} + +impl Clear for Option { + fn clear(&mut self) { + self.take(); + } +} + +impl Clear for String { + fn clear(&mut self) { + String::clear(self); + } +} + +impl Clear for Vec { + fn clear(&mut self) { + Vec::clear(self); + } +} + +#[cfg(feature = "bytes")] +impl Clear for Bytes { + fn clear(&mut self) { + Bytes::clear(self); + } +} diff --git a/third_party/protobuf/src/code_writer.rs b/third_party/protobuf/src/code_writer.rs new file mode 100644 index 000000000..35f37b14d --- /dev/null +++ b/third_party/protobuf/src/code_writer.rs @@ -0,0 +1,364 @@ +use std::io::Write; + +// TODO: should not use wire_format here +use wire_format; + +pub enum Visibility { + Public, + Default, +} + +pub struct CodeWriter<'a> { + writer: &'a mut (Write + 'a), + indent: String, +} + +impl<'a> CodeWriter<'a> { + pub fn new(writer: &'a mut Write) -> CodeWriter<'a> { + CodeWriter { + writer: writer, + indent: "".to_string(), + } + } + + pub fn write_line>(&mut self, line: S) { + (if line.as_ref().is_empty() { + self.writer.write_all("\n".as_bytes()) + } else { + let s: String = [self.indent.as_ref(), line.as_ref(), "\n"].concat(); + self.writer.write_all(s.as_bytes()) + }).unwrap(); + } + + pub fn write_generated(&mut self) { + self.write_line("// This file is generated. Do not edit"); + + // https://secure.phabricator.com/T784 + self.write_line("// @generated"); + + self.write_line(""); + self.comment("https://github.com/Manishearth/rust-clippy/issues/702"); + self.write_line("#![allow(unknown_lints)]"); + self.write_line("#![allow(clippy)]"); + self.write_line(""); + self.write_line("#![cfg_attr(rustfmt, rustfmt_skip)]"); + self.write_line(""); + self.write_line("#![allow(box_pointers)]"); + self.write_line("#![allow(dead_code)]"); + self.write_line("#![allow(missing_docs)]"); + self.write_line("#![allow(non_camel_case_types)]"); + self.write_line("#![allow(non_snake_case)]"); + self.write_line("#![allow(non_upper_case_globals)]"); + self.write_line("#![allow(trivial_casts)]"); + self.write_line("#![allow(unsafe_code)]"); + self.write_line("#![allow(unused_imports)]"); + self.write_line("#![allow(unused_results)]"); + } + + pub fn todo(&mut self, message: &str) { + self.write_line(format!("panic!(\"TODO: {}\");", message)); + } + + pub fn unimplemented(&mut self) { + self.write_line(format!("unimplemented!();")); + } + + pub fn indented(&mut self, cb: F) + where + F : Fn(&mut CodeWriter), + { + cb(&mut CodeWriter { + writer: self.writer, + indent: format!("{} ", self.indent), + }); + } + + #[allow(dead_code)] + pub fn commented(&mut self, cb: F) + where + F : Fn(&mut CodeWriter), + { + cb(&mut CodeWriter { + writer: self.writer, + indent: format!("// {}", self.indent), + }); + } + + pub fn pub_const(&mut self, name: &str, field_type: &str, init: &str) { + self.write_line(&format!("pub const {}: {} = {};", name, field_type, init)); + } + + pub fn lazy_static(&mut self, name: &str, ty: &str) { + self.stmt_block( + &format!( + "static mut {}: ::protobuf::lazy::Lazy<{}> = ::protobuf::lazy::Lazy", + name, + ty + ), + |w| { + w.field_entry("lock", "::protobuf::lazy::ONCE_INIT"); + w.field_entry("ptr", &format!("0 as *const {}", ty)); + }, + ); + } + + pub fn lazy_static_decl_get(&mut self, name: &str, ty: &str, init: F) + where + F : Fn(&mut CodeWriter), + { + self.lazy_static(name, ty); + self.unsafe_expr(|w| { + w.write_line(&format!("{}.get(|| {{", name)); + w.indented(|w| init(w)); + w.write_line(&format!("}})")); + }); + } + + pub fn lazy_static_decl_get_simple(&mut self, name: &str, ty: &str, init: &str) { + self.lazy_static(name, ty); + self.unsafe_expr(|w| { w.write_line(&format!("{}.get({})", name, init)); }); + } + + pub fn block(&mut self, first_line: &str, last_line: &str, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.write_line(first_line); + self.indented(cb); + self.write_line(last_line); + } + + pub fn expr_block(&mut self, prefix: &str, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.block(&format!("{} {{", prefix), "}", cb); + } + + pub fn stmt_block, F>(&mut self, prefix: S, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.block(&format!("{} {{", prefix.as_ref()), "};", cb); + } + + pub fn unsafe_expr(&mut self, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.expr_block("unsafe", cb); + } + + pub fn impl_self_block, F>(&mut self, name: S, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.expr_block(&format!("impl {}", name.as_ref()), cb); + } + + pub fn impl_for_block, S2 : AsRef, F>(&mut self, tr: S1, ty: S2, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.expr_block(&format!("impl {} for {}", tr.as_ref(), ty.as_ref()), cb); + } + + pub fn unsafe_impl(&mut self, what: &str, for_what: &str) { + self.write_line(&format!("unsafe impl {} for {} {{}}", what, for_what)); + } + + pub fn pub_struct, F>(&mut self, name: S, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.expr_block(&format!("pub struct {}", name.as_ref()), cb); + } + + pub fn def_struct, F>(&mut self, name: S, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.expr_block(&format!("struct {}", name.as_ref()), cb); + } + + pub fn pub_enum(&mut self, name: &str, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.expr_block(&format!("pub enum {}", name), cb); + } + + pub fn pub_trait(&mut self, name: &str, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.expr_block(&format!("pub trait {}", name), cb); + } + + pub fn field_entry(&mut self, name: &str, value: &str) { + self.write_line(&format!("{}: {},", name, value)); + } + + pub fn field_decl(&mut self, name: &str, field_type: &str) { + self.write_line(&format!("{}: {},", name, field_type)); + } + + pub fn pub_field_decl(&mut self, name: &str, field_type: &str) { + self.write_line(&format!("pub {}: {},", name, field_type)); + } + + pub fn field_decl_vis(&mut self, vis: Visibility, name: &str, field_type: &str) { + match vis { + Visibility::Public => self.pub_field_decl(name, field_type), + Visibility::Default => self.field_decl(name, field_type), + } + } + + pub fn derive(&mut self, derive: &[&str]) { + let v: Vec = derive.iter().map(|&s| s.to_string()).collect(); + self.write_line(&format!("#[derive({})]", v.join(","))); + } + + pub fn allow(&mut self, what: &[&str]) { + let v: Vec = what.iter().map(|&s| s.to_string()).collect(); + self.write_line(&format!("#[allow({})]", v.join(","))); + } + + pub fn comment(&mut self, comment: &str) { + if comment.is_empty() { + self.write_line("//"); + } else { + self.write_line(&format!("// {}", comment)); + } + } + + pub fn fn_def(&mut self, sig: &str) { + self.write_line(&format!("fn {};", sig)); + } + + pub fn fn_block(&mut self, public: bool, sig: &str, cb: F) + where + F : Fn(&mut CodeWriter), + { + if public { + self.expr_block(&format!("pub fn {}", sig), cb); + } else { + self.expr_block(&format!("fn {}", sig), cb); + } + } + + pub fn pub_fn(&mut self, sig: &str, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.fn_block(true, sig, cb); + } + + pub fn def_fn(&mut self, sig: &str, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.fn_block(false, sig, cb); + } + + pub fn def_mod(&mut self, name: &str, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.expr_block(&format!("mod {}", name), cb) + } + + pub fn pub_mod(&mut self, name: &str, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.expr_block(&format!("pub mod {}", name), cb) + } + + pub fn while_block, F>(&mut self, cond: S, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.expr_block(&format!("while {}", cond.as_ref()), cb); + } + + // if ... { ... } + pub fn if_stmt, F>(&mut self, cond: S, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.expr_block(&format!("if {}", cond.as_ref()), cb); + } + + // if ... {} else { ... } + pub fn if_else_stmt, F>(&mut self, cond: S, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.write_line(&format!("if {} {{", cond.as_ref())); + self.write_line("} else {"); + self.indented(cb); + self.write_line("}"); + } + + // if let ... = ... { ... } + pub fn if_let_stmt(&mut self, decl: &str, expr: &str, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.if_stmt(&format!("let {} = {}", decl, expr), cb); + } + + // if let ... = ... { } else { ... } + pub fn if_let_else_stmt(&mut self, decl: &str, expr: &str, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.if_else_stmt(&format!("let {} = {}", decl, expr), cb); + } + + pub fn for_stmt, S2 : AsRef, F>(&mut self, over: S1, varn: S2, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.stmt_block(&format!("for {} in {}", varn.as_ref(), over.as_ref()), cb) + } + + pub fn match_block, F>(&mut self, value: S, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.stmt_block(&format!("match {}", value.as_ref()), cb); + } + + pub fn match_expr, F>(&mut self, value: S, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.expr_block(&format!("match {}", value.as_ref()), cb); + } + + pub fn case_block, F>(&mut self, cond: S, cb: F) + where + F : Fn(&mut CodeWriter), + { + self.block(&format!("{} => {{", cond.as_ref()), "},", cb); + } + + pub fn case_expr, S2 : AsRef>(&mut self, cond: S1, body: S2) { + self.write_line(&format!("{} => {},", cond.as_ref(), body.as_ref())); + } + + pub fn error_unexpected_wire_type(&mut self, wire_type: &str) { + self.write_line(&format!( + "return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type({}));", + wire_type + )); + } + + pub fn assert_wire_type(&mut self, wire_type: wire_format::WireType) { + self.if_stmt(&format!("wire_type != ::protobuf::wire_format::{:?}", wire_type), |w| { + w.error_unexpected_wire_type("wire_type"); + }); + } +} diff --git a/third_party/protobuf/src/codegen/enums.rs b/third_party/protobuf/src/codegen/enums.rs new file mode 100644 index 000000000..23c755162 --- /dev/null +++ b/third_party/protobuf/src/codegen/enums.rs @@ -0,0 +1,266 @@ +use std::collections::HashSet; + +use descriptor::*; +use descriptorx::*; +use code_writer::*; + + +#[derive(Clone)] +pub struct EnumValueGen { + proto: EnumValueDescriptorProto, + enum_rust_name: String, +} + +impl EnumValueGen { + fn parse(proto: &EnumValueDescriptorProto, enum_rust_name: &str) -> EnumValueGen { + EnumValueGen { + proto: proto.clone(), + enum_rust_name: enum_rust_name.to_string(), + } + } + + // enum value + fn number(&self) -> i32 { + self.proto.get_number() + } + + // name of enum variant in generated rust code + fn rust_name_inner(&self) -> String { + self.proto.rust_name() + } + + pub fn rust_name_outer(&self) -> String { + let mut r = String::new(); + r.push_str(&self.enum_rust_name); + r.push_str("::"); + r.push_str(&self.rust_name_inner()); + r + } +} + + +pub struct EnumGen<'a> { + enum_with_scope: &'a EnumWithScope<'a>, + type_name: String, + lite_runtime: bool, +} + +impl<'a> EnumGen<'a> { + pub fn new( + enum_with_scope: &'a EnumWithScope<'a>, + current_file: &FileDescriptorProto, + ) -> EnumGen<'a> { + let rust_name = if enum_with_scope.get_scope().get_file_descriptor().get_name() == + current_file.get_name() + { + // field type is a message or enum declared in the same file + enum_with_scope.rust_name() + } else { + format!( + "super::{}::{}", + proto_path_to_rust_mod( + enum_with_scope.get_scope().get_file_descriptor().get_name(), + ), + enum_with_scope.rust_name() + ) + }; + EnumGen { + enum_with_scope: enum_with_scope, + type_name: rust_name, + lite_runtime: enum_with_scope + .get_scope() + .get_file_descriptor() + .get_options() + .get_optimize_for() == + FileOptions_OptimizeMode::LITE_RUNTIME, + } + } + + fn allow_alias(&self) -> bool { + self.enum_with_scope.en.get_options().get_allow_alias() + } + + fn values_all(&self) -> Vec { + let mut r = Vec::new(); + for p in self.enum_with_scope.values() { + r.push(EnumValueGen::parse(p, &self.type_name)); + } + r + } + + pub fn values_unique(&self) -> Vec { + let mut used = HashSet::new(); + let mut r = Vec::new(); + for p in self.enum_with_scope.values() { + // skipping non-unique enums + // TODO: should support it + if !used.insert(p.get_number()) { + continue; + } + r.push(EnumValueGen::parse(p, &self.type_name)); + } + r + } + + // find enum value by name + pub fn value_by_name(&'a self, name: &str) -> EnumValueGen { + EnumValueGen::parse(self.enum_with_scope.value_by_name(name), &self.type_name) + } + + pub fn write(&self, w: &mut CodeWriter) { + self.write_struct(w); + if self.allow_alias() { + w.write_line(""); + self.write_impl_eq(w); + w.write_line(""); + self.write_impl_hash(w); + } + w.write_line(""); + self.write_impl_enum(w); + w.write_line(""); + self.write_impl_copy(w); + if self.enum_with_scope.scope.file_scope.syntax() == Syntax::PROTO3 { + w.write_line(""); + self.write_impl_default(w); + } + w.write_line(""); + self.write_impl_value(w); + } + + fn write_struct(&self, w: &mut CodeWriter) { + let mut derive = Vec::new(); + derive.push("Clone"); + if !self.allow_alias() { + derive.push("PartialEq"); + } + derive.push("Eq"); + derive.push("Debug"); + if !self.allow_alias() { + derive.push("Hash"); + } else { + w.comment( + "Note: you cannot use pattern matching for enums with allow_alias option", + ); + } + w.derive(&derive); + let ref type_name = self.type_name; + w.expr_block(&format!("pub enum {}", type_name), |w| { + for value in self.values_all() { + if self.allow_alias() { + w.write_line(&format!( + "{}, // {}", + value.rust_name_inner(), + value.number() + )); + } else { + w.write_line(&format!( + "{} = {},", + value.rust_name_inner(), + value.number() + )); + } + } + }); + } + + fn write_fn_value(&self, w: &mut CodeWriter) { + w.def_fn("value(&self) -> i32", |w| if self.allow_alias() { + w.match_expr("*self", |w| for value in self.values_all() { + w.case_expr(value.rust_name_outer(), format!("{}", value.number())); + }); + } else { + w.write_line("*self as i32") + }); + } + + fn write_impl_enum(&self, w: &mut CodeWriter) { + let ref type_name = self.type_name; + w.impl_for_block("::protobuf::ProtobufEnum", &type_name, |w| { + self.write_fn_value(w); + + w.write_line(""); + let ref type_name = self.type_name; + w.def_fn(&format!("from_i32(value: i32) -> ::std::option::Option<{}>", type_name), |w| { + w.match_expr("value", |w| { + let values = self.values_unique(); + for value in values { + w.write_line(&format!("{} => ::std::option::Option::Some({}),", + value.number(), value.rust_name_outer())); + } + w.write_line(&format!("_ => ::std::option::Option::None")); + }); + }); + + w.write_line(""); + w.def_fn(&format!("values() -> &'static [Self]"), |w| { + w.write_line(&format!("static values: &'static [{}] = &[", type_name)); + w.indented(|w| { + for value in self.values_all() { + w.write_line(&format!("{},", value.rust_name_outer())); + } + }); + w.write_line("];"); + w.write_line("values"); + }); + + if !self.lite_runtime { + w.write_line(""); + let ref type_name = self.type_name; + w.def_fn(&format!("enum_descriptor_static(_: ::std::option::Option<{}>) -> &'static ::protobuf::reflect::EnumDescriptor", type_name), |w| { + w.lazy_static_decl_get("descriptor", "::protobuf::reflect::EnumDescriptor", |w| { + let ref type_name = self.type_name; + w.write_line(&format!("::protobuf::reflect::EnumDescriptor::new(\"{}\", file_descriptor_proto())", type_name)); + }); + }); + } + }); + } + + fn write_impl_value(&self, w: &mut CodeWriter) { + w.impl_for_block("::protobuf::reflect::ProtobufValue", &self.type_name, |w| { + w.def_fn( + "as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef", + |w| { + w.write_line( + "::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor())", + ) + }, + ) + }) + } + + fn write_impl_copy(&self, w: &mut CodeWriter) { + w.impl_for_block("::std::marker::Copy", &self.type_name, |_w| {}); + } + + fn write_impl_eq(&self, w: &mut CodeWriter) { + assert!(self.allow_alias()); + w.impl_for_block("::std::cmp::PartialEq", &self.type_name, |w| { + w.def_fn("eq(&self, other: &Self) -> bool", |w| { + w.write_line("self.value() == other.value()"); + }); + }); + } + + fn write_impl_hash(&self, w: &mut CodeWriter) { + assert!(self.allow_alias()); + w.impl_for_block("::std::hash::Hash", &self.type_name, |w| { + w.def_fn("hash(&self, state: &mut H)", |w| { + w.write_line("state.write_i32(self.value())"); + }); + }); + } + + fn write_impl_default(&self, w: &mut CodeWriter) { + assert!(self.enum_with_scope.scope.file_scope.syntax() == Syntax::PROTO3); + w.impl_for_block("::std::default::Default", &self.type_name, |w| { + w.def_fn("default() -> Self", |w| { + w.write_line(&format!( + "{}::{}", + &self.type_name, + &self.enum_with_scope.values()[0].rust_name() + )) + }); + }); + } +} diff --git a/third_party/protobuf/src/codegen/extensions.rs b/third_party/protobuf/src/codegen/extensions.rs new file mode 100644 index 000000000..1e285ec94 --- /dev/null +++ b/third_party/protobuf/src/codegen/extensions.rs @@ -0,0 +1,91 @@ +use descriptor::*; +use descriptorx::*; +use code_writer::CodeWriter; +use super::rust_types_values::*; + + +struct ExtGen<'a> { + file: &'a FileDescriptorProto, + root_scope: &'a RootScope<'a>, + field: &'a FieldDescriptorProto, +} + +impl<'a> ExtGen<'a> { + fn extendee_rust_name(&self) -> String { + type_name_to_rust_relative(self.field.get_extendee(), self.file, true, self.root_scope) + } + + fn repeated(&self) -> bool { + match self.field.get_label() { + FieldDescriptorProto_Label::LABEL_REPEATED => true, + FieldDescriptorProto_Label::LABEL_OPTIONAL => false, + FieldDescriptorProto_Label::LABEL_REQUIRED => { + panic!("required ext field: {}", self.field.get_name()) + } + } + } + + fn return_type_gen(&self) -> ProtobufTypeGen { + if self.field.has_type_name() { + let rust_name_relative = type_name_to_rust_relative( + self.field.get_type_name(), + self.file, + true, + self.root_scope, + ); + match self.field.get_field_type() { + FieldDescriptorProto_Type::TYPE_MESSAGE => ProtobufTypeGen::Message( + rust_name_relative, + ), + FieldDescriptorProto_Type::TYPE_ENUM => ProtobufTypeGen::Enum(rust_name_relative), + t => panic!("unknown type: {:?}", t), + } + } else { + ProtobufTypeGen::Primitive(self.field.get_field_type(), PrimitiveTypeVariant::Default) + } + } + + fn write(&self, w: &mut CodeWriter) { + let suffix = if self.repeated() { + "Repeated" + } else { + "Optional" + }; + let field_type = format!("::protobuf::ext::ExtField{}", suffix); + w.pub_const( + self.field.get_name(), // TODO: escape + &format!( + "{}<{}, {}>", + field_type, + self.extendee_rust_name(), + self.return_type_gen().rust_type() + ), + &format!( + "{} {{ field_number: {}, phantom: ::std::marker::PhantomData }}", + field_type, + self.field.get_number() + ), + ); + } +} + + +pub fn write_extensions(file: &FileDescriptorProto, root_scope: &RootScope, w: &mut CodeWriter) { + if file.get_extension().is_empty() { + return; + } + + w.write_line(""); + w.pub_mod("exts", |w| { + w.write_line("use protobuf::Message as Message_imported_for_functions;"); + + for field in file.get_extension() { + w.write_line(""); + ExtGen { + file: file, + root_scope: root_scope, + field: field, + }.write(w); + } + }); +} diff --git a/third_party/protobuf/src/codegen/field.rs b/third_party/protobuf/src/codegen/field.rs new file mode 100644 index 000000000..33c5fc715 --- /dev/null +++ b/third_party/protobuf/src/codegen/field.rs @@ -0,0 +1,2065 @@ +use descriptor::*; +use descriptorx::*; +use rustproto; +use wire_format; +use rt; +use rust; +use text_format; +use code_writer::CodeWriter; +use types::ProtobufType; +use reflect::ProtobufValue; + +use ext::ExtFieldOptional; + +use super::message::*; +use super::rust_types_values::*; +use super::enums::*; + + + +fn type_is_copy(field_type: FieldDescriptorProto_Type) -> bool { + match field_type { + FieldDescriptorProto_Type::TYPE_MESSAGE | + FieldDescriptorProto_Type::TYPE_STRING | + FieldDescriptorProto_Type::TYPE_BYTES => false, + _ => true, + } +} + +impl FieldDescriptorProto_Type { + fn read(&self, is: &str) -> String { + format!("{}.read_{}()", is, protobuf_name(*self)) + } + + /// True if self is signed integer with zigzag encoding + fn is_s_varint(&self) -> bool { + match *self { + FieldDescriptorProto_Type::TYPE_SINT32 | + FieldDescriptorProto_Type::TYPE_SINT64 => true, + _ => false, + } + } +} + +fn field_type_wire_type(field_type: FieldDescriptorProto_Type) -> wire_format::WireType { + use stream::wire_format::*; + match field_type { + FieldDescriptorProto_Type::TYPE_INT32 => WireTypeVarint, + FieldDescriptorProto_Type::TYPE_INT64 => WireTypeVarint, + FieldDescriptorProto_Type::TYPE_UINT32 => WireTypeVarint, + FieldDescriptorProto_Type::TYPE_UINT64 => WireTypeVarint, + FieldDescriptorProto_Type::TYPE_SINT32 => WireTypeVarint, + FieldDescriptorProto_Type::TYPE_SINT64 => WireTypeVarint, + FieldDescriptorProto_Type::TYPE_BOOL => WireTypeVarint, + FieldDescriptorProto_Type::TYPE_ENUM => WireTypeVarint, + FieldDescriptorProto_Type::TYPE_FIXED32 => WireTypeFixed32, + FieldDescriptorProto_Type::TYPE_FIXED64 => WireTypeFixed64, + FieldDescriptorProto_Type::TYPE_SFIXED32 => WireTypeFixed32, + FieldDescriptorProto_Type::TYPE_SFIXED64 => WireTypeFixed64, + FieldDescriptorProto_Type::TYPE_FLOAT => WireTypeFixed32, + FieldDescriptorProto_Type::TYPE_DOUBLE => WireTypeFixed64, + FieldDescriptorProto_Type::TYPE_STRING => WireTypeLengthDelimited, + FieldDescriptorProto_Type::TYPE_BYTES => WireTypeLengthDelimited, + FieldDescriptorProto_Type::TYPE_MESSAGE => WireTypeLengthDelimited, + FieldDescriptorProto_Type::TYPE_GROUP => WireTypeLengthDelimited, // not true + } +} + +fn type_protobuf_name(field_type: FieldDescriptorProto_Type) -> &'static str { + match field_type { + FieldDescriptorProto_Type::TYPE_INT32 => "int32", + FieldDescriptorProto_Type::TYPE_INT64 => "int64", + FieldDescriptorProto_Type::TYPE_UINT32 => "uint32", + FieldDescriptorProto_Type::TYPE_UINT64 => "uint64", + FieldDescriptorProto_Type::TYPE_SINT32 => "sint32", + FieldDescriptorProto_Type::TYPE_SINT64 => "sint64", + FieldDescriptorProto_Type::TYPE_BOOL => "bool", + FieldDescriptorProto_Type::TYPE_FIXED32 => "fixed32", + FieldDescriptorProto_Type::TYPE_FIXED64 => "fixed64", + FieldDescriptorProto_Type::TYPE_SFIXED32 => "sfixed32", + FieldDescriptorProto_Type::TYPE_SFIXED64 => "sfixed64", + FieldDescriptorProto_Type::TYPE_FLOAT => "float", + FieldDescriptorProto_Type::TYPE_DOUBLE => "double", + FieldDescriptorProto_Type::TYPE_STRING => "string", + FieldDescriptorProto_Type::TYPE_BYTES => "bytes", + FieldDescriptorProto_Type::TYPE_ENUM | + FieldDescriptorProto_Type::TYPE_MESSAGE | + FieldDescriptorProto_Type::TYPE_GROUP => panic!(), + } +} + +fn field_type_protobuf_name<'a>(field: &'a FieldDescriptorProto) -> &'a str { + if field.has_type_name() { + field.get_type_name() + } else { + type_protobuf_name(field.get_field_type()) + } +} + +// size of value for type, None if variable +fn field_type_size(field_type: FieldDescriptorProto_Type) -> Option { + match field_type { + FieldDescriptorProto_Type::TYPE_BOOL => Some(1), + t if field_type_wire_type(t) == wire_format::WireTypeFixed32 => Some(4), + t if field_type_wire_type(t) == wire_format::WireTypeFixed64 => Some(8), + _ => None, + } +} + + +#[derive(Clone, Debug)] +struct EntryKeyValue(GenProtobufType, GenProtobufType); + +#[derive(Clone, Debug)] +pub enum GenProtobufType { + Primitive(FieldDescriptorProto_Type, PrimitiveTypeVariant), + // name, file name + Message(String, String), + // name, file name, default value + Enum(String, String, String), + Group, +} + +impl GenProtobufType { + fn proto_type(&self) -> FieldDescriptorProto_Type { + match *self { + GenProtobufType::Primitive(t, ..) => t, + GenProtobufType::Group => FieldDescriptorProto_Type::TYPE_GROUP, + GenProtobufType::Message(..) => FieldDescriptorProto_Type::TYPE_MESSAGE, + GenProtobufType::Enum(..) => FieldDescriptorProto_Type::TYPE_ENUM, + } + } + + fn is_copy(&self) -> bool { + type_is_copy(self.proto_type()) + } + + pub fn rust_type(&self) -> RustType { + match *self { + GenProtobufType::Primitive(t, PrimitiveTypeVariant::Default) => rust_name(t), + GenProtobufType::Primitive( + FieldDescriptorProto_Type::TYPE_STRING, + PrimitiveTypeVariant::Carllerche, + ) => RustType::Chars, + GenProtobufType::Primitive( + FieldDescriptorProto_Type::TYPE_BYTES, + PrimitiveTypeVariant::Carllerche, + ) => RustType::Bytes, + GenProtobufType::Primitive(.., PrimitiveTypeVariant::Carllerche) => unreachable!(), + GenProtobufType::Group => RustType::Group, + GenProtobufType::Message(ref name, _) => RustType::Message(name.clone()), + GenProtobufType::Enum(ref name, _, ref default_value) => { + RustType::Enum(name.clone(), default_value.clone()) + } + } + } + + fn protobuf_type_gen(&self) -> ProtobufTypeGen { + match *self { + GenProtobufType::Primitive(t, v) => ProtobufTypeGen::Primitive(t, v), + GenProtobufType::Message(ref name, ..) => ProtobufTypeGen::Message(name.clone()), + GenProtobufType::Enum(ref name, ..) => ProtobufTypeGen::Enum(name.clone()), + GenProtobufType::Group => unreachable!(), + } + } + + /// implementation of ProtobufType trait + fn lib_protobuf_type(&self) -> String { + self.protobuf_type_gen().rust_type() + } + + fn primitive_type_variant(&self) -> PrimitiveTypeVariant { + match self { + &GenProtobufType::Primitive(_, v) => v, + _ => PrimitiveTypeVariant::Default, + } + } +} + +#[derive(Clone, PartialEq, Eq)] +pub enum SingularFieldFlag { + // proto2 or proto3 message + WithFlag { required: bool }, + // proto3 + WithoutFlag, +} + +impl SingularFieldFlag { + pub fn is_required(&self) -> bool { + match *self { + SingularFieldFlag::WithFlag { required } => required, + SingularFieldFlag::WithoutFlag => false, + } + } +} + +#[derive(Clone)] +pub struct SingularField { + pub flag: SingularFieldFlag, + pub elem: GenProtobufType, +} + +impl SingularField { + fn rust_type(&self) -> RustType { + match self.flag { + SingularFieldFlag::WithFlag { .. } => { + match self.elem.proto_type() { + FieldDescriptorProto_Type::TYPE_MESSAGE => RustType::SingularPtrField( + Box::new(self.elem.rust_type()), + ), + FieldDescriptorProto_Type::TYPE_STRING | + FieldDescriptorProto_Type::TYPE_BYTES + if self.elem.primitive_type_variant() == PrimitiveTypeVariant::Default => { + RustType::SingularField(Box::new(self.elem.rust_type())) + } + _ => RustType::Option(Box::new(self.elem.rust_type())), + } + } + SingularFieldFlag::WithoutFlag => self.elem.rust_type(), + } + } +} + +// oneof one { ... } +#[derive(Clone)] +pub struct OneofField { + elem: GenProtobufType, + oneof_name: String, + oneof_type_name: RustType, + boxed: bool, +} + +impl OneofField { + fn parse( + oneof: &OneofWithContext, + _field: &FieldDescriptorProto, + elem: GenProtobufType, + ) -> OneofField { + // detecting recursion + let boxed = if let &GenProtobufType::Message(ref name, ..) = &elem { + if *name == oneof.message.rust_name() { + true + } else { + false + } + } else { + false + }; + + OneofField { + elem: elem, + oneof_name: oneof.name().to_string(), + oneof_type_name: RustType::Oneof(oneof.rust_name()), + boxed: boxed, + } + } + + fn rust_type(&self) -> RustType { + let t = self.elem.rust_type(); + + if self.boxed { + RustType::Uniq(Box::new(t)) + } else { + t + } + } +} + +#[derive(Clone)] +pub struct RepeatedField { + pub elem: GenProtobufType, + pub packed: bool, +} + +impl RepeatedField { + fn rust_type(&self) -> RustType { + if !self.elem.is_copy() && + self.elem.primitive_type_variant() != PrimitiveTypeVariant::Carllerche + { + RustType::RepeatedField(Box::new(self.elem.rust_type())) + } else { + RustType::Vec(Box::new(self.elem.rust_type())) + } + } +} + +#[derive(Clone)] +pub struct MapField { + name: String, + key: GenProtobufType, + value: GenProtobufType, +} + +#[derive(Clone)] +pub enum FieldKind { + // optional or required + Singular(SingularField), + // repeated except map + Repeated(RepeatedField), + // map + Map(MapField), + // part of oneof + Oneof(OneofField), +} + +impl FieldKind { + fn primitive_type_variant(&self) -> PrimitiveTypeVariant { + match self { + &FieldKind::Singular(ref s) => s.elem.primitive_type_variant(), + &FieldKind::Repeated(ref r) => r.elem.primitive_type_variant(), + _ => panic!("not a primitive type"), // TODO: map + } + } +} + +enum FieldElem { + Primitive(FieldDescriptorProto_Type, PrimitiveTypeVariant), + // name, file name, entry + Message(String, String, Option>), + // name, file name, default value + Enum(String, String, String), + Group, +} + +impl FieldElem { + fn into_type(self) -> GenProtobufType { + match self { + FieldElem::Primitive(t, v) => GenProtobufType::Primitive(t, v), + FieldElem::Message(name, file_name, None) => GenProtobufType::Message(name, file_name), + // TODO: replace with unreachable + FieldElem::Message(name, file_name, Some(..)) => { + GenProtobufType::Message(name, file_name) + } + FieldElem::Enum(name, file_name, default_value) => { + GenProtobufType::Enum(name, file_name, default_value) + } + FieldElem::Group => GenProtobufType::Group, + } + } +} + +fn join_field_ext>( + source: &FieldWithContext, + field_ext: ExtFieldOptional, + message_ext: ExtFieldOptional, + file_ext: ExtFieldOptional, +) -> Option { + if let Some(v) = field_ext.get(source.field.get_options()) { + return Some(v); + } + for m in source.containing_messages() { + if let Some(v) = message_ext.get(m.get_options()) { + return Some(v); + } + } + return file_ext.get(source.message.scope.get_file_descriptor().get_options()); +} + +fn field_elem( + field: &FieldWithContext, + root_scope: &RootScope, + parse_map: bool, +) -> (FieldElem, Option) { + if field.field.get_field_type() == FieldDescriptorProto_Type::TYPE_GROUP { + (FieldElem::Group, None) + } else if field.field.has_type_name() { + let message_or_enum = root_scope.find_message_or_enum(field.field.get_type_name()); + let file_name = message_or_enum + .get_scope() + .file_scope + .file_descriptor + .get_name() + .to_owned(); + let rust_relative_name = type_name_to_rust_relative( + field.field.get_type_name(), + field.message.get_scope().file_scope.file_descriptor, + false, + root_scope, + ); + match (field.field.get_field_type(), message_or_enum) { + ( + FieldDescriptorProto_Type::TYPE_MESSAGE, + MessageOrEnumWithScope::Message(message_with_scope), + ) => { + let entry_key_value = if let (true, Some((key, value))) = + (parse_map, message_with_scope.map_entry()) + { + Some(Box::new(EntryKeyValue( + field_elem(&key, root_scope, false).0.into_type(), + field_elem(&value, root_scope, false).0.into_type(), + ))) + } else { + None + }; + ( + FieldElem::Message(rust_relative_name, file_name, entry_key_value), + None, + ) + } + ( + FieldDescriptorProto_Type::TYPE_ENUM, + MessageOrEnumWithScope::Enum(enum_with_scope), + ) => { + let e = EnumGen::new( + &enum_with_scope, + field.message.get_scope().get_file_descriptor(), + ); + let ev = if field.field.has_default_value() { + e.value_by_name(field.field.get_default_value()).clone() + } else { + e.values_unique().into_iter().next().unwrap() + }; + ( + FieldElem::Enum( + rust_relative_name, + file_name, + enum_with_scope.values()[0].get_name().to_owned(), + ), + Some(ev), + ) + } + _ => panic!("unknown named type: {:?}", field.field.get_field_type()), + } + } else if field.field.has_field_type() { + let carllerche_for_bytes = join_field_ext( + field, + rustproto::exts::carllerche_bytes_for_bytes_field, + rustproto::exts::carllerche_bytes_for_bytes, + rustproto::exts::carllerche_bytes_for_bytes_all, + ).unwrap_or(false); + let carllerche_for_string = join_field_ext( + field, + rustproto::exts::carllerche_bytes_for_string_field, + rustproto::exts::carllerche_bytes_for_string, + rustproto::exts::carllerche_bytes_for_string_all, + ).unwrap_or(false); + + let elem = match field.field.get_field_type() { + FieldDescriptorProto_Type::TYPE_STRING if carllerche_for_string => { + FieldElem::Primitive( + FieldDescriptorProto_Type::TYPE_STRING, + PrimitiveTypeVariant::Carllerche, + ) + } + FieldDescriptorProto_Type::TYPE_BYTES if carllerche_for_bytes => { + FieldElem::Primitive( + FieldDescriptorProto_Type::TYPE_BYTES, + PrimitiveTypeVariant::Carllerche, + ) + } + t => FieldElem::Primitive(t, PrimitiveTypeVariant::Default), + }; + + (elem, None) + } else { + panic!( + "neither type_name, nor field_type specified for field: {}", + field.field.get_name() + ); + } +} + +pub struct AccessorFn { + name: String, + for_reflect_suffix: bool, + type_params: Vec, + pub accessors: Vec, +} + +impl AccessorFn { + pub fn sig(&self) -> String { + let mut s = self.name.clone(); + s.push_str("::<_"); + for p in &self.type_params { + s.push_str(", "); + s.push_str(&p); + } + s.push_str(">"); + s + } +} + +#[derive(Clone)] +pub struct FieldGen<'a> { + root_scope: &'a RootScope<'a>, + syntax: Syntax, + pub proto_field: FieldWithContext<'a>, + // field name in generated code + pub rust_name: String, + pub proto_type: FieldDescriptorProto_Type, + wire_type: wire_format::WireType, + enum_default_value: Option, + pub kind: FieldKind, + pub expose_field: bool, + pub generate_accessors: bool, +} + +impl<'a> FieldGen<'a> { + pub fn parse(field: FieldWithContext<'a>, root_scope: &'a RootScope<'a>) -> FieldGen<'a> { + let (elem, enum_default_value) = field_elem(&field, root_scope, true); + + let default_expose_field = field.message.scope.file_scope.syntax() == Syntax::PROTO3; + + let expose_field = join_field_ext( + &field, + rustproto::exts::expose_fields_field, + rustproto::exts::expose_fields, + rustproto::exts::expose_fields_all, + ).unwrap_or(default_expose_field); + + let generate_accessors = join_field_ext( + &field, + rustproto::exts::generate_accessors_field, + rustproto::exts::generate_accessors, + rustproto::exts::generate_accessors_all, + ).unwrap_or(true); + + let kind = if field.field.get_label() == FieldDescriptorProto_Label::LABEL_REPEATED { + match (elem, true) { + // map field + (FieldElem::Message(name, _, Some(key_value)), true) => FieldKind::Map(MapField { + name: name, + key: key_value.0.clone(), + value: key_value.1.clone(), + }), + // regular repeated field + (elem, _) => FieldKind::Repeated(RepeatedField { + elem: elem.into_type(), + packed: field.field.get_options().get_packed(), + }), + } + } else if let Some(oneof) = field.oneof() { + FieldKind::Oneof(OneofField::parse(&oneof, field.field, elem.into_type())) + } else { + let flag = if field.message.scope.file_scope.syntax() == Syntax::PROTO3 && + field.field.get_field_type() != FieldDescriptorProto_Type::TYPE_MESSAGE + { + SingularFieldFlag::WithoutFlag + } else { + SingularFieldFlag::WithFlag { + required: field.field.get_label() == FieldDescriptorProto_Label::LABEL_REQUIRED, + } + }; + FieldKind::Singular(SingularField { + elem: elem.into_type(), + flag: flag, + }) + }; + + FieldGen { + root_scope: root_scope, + syntax: field.message.get_scope().file_scope.syntax(), + rust_name: field.rust_name(), + proto_type: field.field.get_field_type(), + wire_type: field_type_wire_type(field.field.get_field_type()), + enum_default_value: enum_default_value, + proto_field: field, + kind: kind, + expose_field: expose_field, + generate_accessors: generate_accessors, + } + } + + fn tag_size(&self) -> u32 { + rt::tag_size(self.proto_field.number()) + } + + pub fn is_oneof(&self) -> bool { + match self.kind { + FieldKind::Oneof(..) => true, + _ => false, + } + } + + fn oneof(&self) -> &OneofField { + match self.kind { + FieldKind::Oneof(ref oneof) => &oneof, + _ => panic!("not a oneof field: {}", self.reconstruct_def()), + } + } + + fn is_singular(&self) -> bool { + match self.kind { + FieldKind::Singular(..) => true, + _ => false, + } + } + + fn is_repeated_not_map(&self) -> bool { + match self.kind { + FieldKind::Repeated(..) => true, + _ => false, + } + } + + fn is_repeated_or_map(&self) -> bool { + match self.kind { + FieldKind::Repeated(..) | + FieldKind::Map(..) => true, + _ => false, + } + } + + fn is_repeated_packed(&self) -> bool { + match self.kind { + FieldKind::Repeated(RepeatedField { packed: true, .. }) => true, + _ => false, + } + } + + #[allow(dead_code)] + fn repeated(&self) -> &RepeatedField { + match self.kind { + FieldKind::Repeated(ref repeated) => &repeated, + _ => panic!("not a repeated field: {}", self.reconstruct_def()), + } + } + + fn singular(&self) -> &SingularField { + match self.kind { + FieldKind::Singular(ref singular) => &singular, + _ => panic!("not a singular field: {}", self.reconstruct_def()), + } + } + + fn map(&self) -> &MapField { + match self.kind { + FieldKind::Map(ref map) => &map, + _ => panic!("not a map field: {}", self.reconstruct_def()), + } + } + + fn variant_path(&self) -> String { + // TODO: should reuse code from OneofVariantGen + format!("{}::{}", self.oneof().oneof_type_name, self.rust_name) + } + + // TODO: drop it + pub fn elem(&self) -> &GenProtobufType { + match self.kind { + FieldKind::Singular(SingularField { ref elem, .. }) => &elem, + FieldKind::Repeated(RepeatedField { ref elem, .. }) => &elem, + FieldKind::Oneof(OneofField { ref elem, .. }) => &elem, + FieldKind::Map(..) => unreachable!(), + } + } + + // type of field in struct + pub fn full_storage_type(&self) -> RustType { + match self.kind { + FieldKind::Repeated(ref repeated) => repeated.rust_type(), + FieldKind::Map(MapField { ref key, ref value, .. }) => { + RustType::HashMap(Box::new(key.rust_type()), Box::new(value.rust_type())) + } + FieldKind::Singular(ref singular) => singular.rust_type(), + FieldKind::Oneof(..) => unreachable!(), + } + } + + // type of `v` in `for v in field` + fn full_storage_iter_elem_type(&self) -> RustType { + if let FieldKind::Oneof(ref oneof) = self.kind { + oneof.elem.rust_type() + } else { + self.full_storage_type().iter_elem_type() + } + } + + // suffix `xxx` as in `os.write_xxx_no_tag(..)` + fn os_write_fn_suffix(&self) -> &str { + match self.proto_type { + FieldDescriptorProto_Type::TYPE_MESSAGE => "message", + FieldDescriptorProto_Type::TYPE_ENUM => "enum", + ty => protobuf_name(ty), + } + } + + // type of `v` in `os.write_xxx_no_tag(v)` + fn os_write_fn_param_type(&self) -> RustType { + match self.proto_type { + FieldDescriptorProto_Type::TYPE_STRING => RustType::Ref(Box::new(RustType::Str)), + FieldDescriptorProto_Type::TYPE_BYTES => RustType::Ref( + Box::new(RustType::Slice(Box::new(RustType::Int(false, 8)))), + ), + FieldDescriptorProto_Type::TYPE_ENUM => RustType::Int(true, 32), + t => rust_name(t), + } + } + + // for field `foo`, type of param of `fn set_foo(..)` + fn set_xxx_param_type(&self) -> RustType { + match self.kind { + FieldKind::Singular(SingularField { ref elem, .. }) | + FieldKind::Oneof(OneofField { ref elem, .. }) => elem.rust_type(), + FieldKind::Repeated(..) | + FieldKind::Map(..) => self.full_storage_type(), + } + } + + // for field `foo`, return type if `fn take_foo(..)` + fn take_xxx_return_type(&self) -> RustType { + self.set_xxx_param_type() + } + + // for field `foo`, return type of `fn mut_foo(..)` + fn mut_xxx_return_type(&self) -> RustType { + RustType::Ref(Box::new(match self.kind { + FieldKind::Singular(SingularField { ref elem, .. }) | + FieldKind::Oneof(OneofField { ref elem, .. }) => elem.rust_type(), + FieldKind::Repeated(..) | + FieldKind::Map(..) => self.full_storage_type(), + })) + } + + // for field `foo`, return type of `fn get_foo(..)` + fn get_xxx_return_type(&self) -> RustType { + match self.kind { + FieldKind::Singular(SingularField { ref elem, .. }) | + FieldKind::Oneof(OneofField { ref elem, .. }) => { + match elem.is_copy() { + true => elem.rust_type(), + false => elem.rust_type().ref_type(), + } + } + FieldKind::Repeated(RepeatedField { ref elem, .. }) => { + RustType::Ref(Box::new(RustType::Slice(Box::new(elem.rust_type())))) + } + FieldKind::Map(..) => RustType::Ref(Box::new(self.full_storage_type())), + } + } + + // fixed size type? + fn is_fixed(&self) -> bool { + field_type_size(self.proto_type).is_some() + } + + // must use zigzag encoding? + fn is_zigzag(&self) -> bool { + match self.proto_type { + FieldDescriptorProto_Type::TYPE_SINT32 | + FieldDescriptorProto_Type::TYPE_SINT64 => true, + _ => false, + } + } + + // data is enum + fn is_enum(&self) -> bool { + match self.proto_type { + FieldDescriptorProto_Type::TYPE_ENUM => true, + _ => false, + } + } + + // elem data is not stored in heap + pub fn elem_type_is_copy(&self) -> bool { + type_is_copy(self.proto_type) + } + + fn defaut_value_from_proto_float(&self) -> String { + let type_name = match self.proto_type { + FieldDescriptorProto_Type::TYPE_FLOAT => "f32", + FieldDescriptorProto_Type::TYPE_DOUBLE => "f64", + _ => unreachable!(), + }; + let proto_default = self.proto_field.field.get_default_value(); + + fn parse_special_float(s: &str) -> Option<&'static str> { + if s == "nan" { + Some("NAN") + } else if s == "inf" { + Some("INFINITY") + } else if s == "-inf" { + Some("NEG_INFINITY") + } else { + None + } + } + + match parse_special_float(proto_default) { + Some(special) => format!("::std::{}::{}", type_name, special), + // hope it is decimal float + None => format!("{}{}", proto_default, type_name), + } + } + + fn default_value_from_proto(&self) -> Option { + assert!(self.is_singular() || self.is_oneof()); + if self.enum_default_value.is_some() { + Some(self.enum_default_value.as_ref().unwrap().rust_name_outer()) + } else if self.proto_field.field.has_default_value() { + let proto_default = self.proto_field.field.get_default_value(); + Some(match self.proto_type { + // For numeric types, contains the original text representation of the value + FieldDescriptorProto_Type::TYPE_DOUBLE | + FieldDescriptorProto_Type::TYPE_FLOAT => self.defaut_value_from_proto_float(), + FieldDescriptorProto_Type::TYPE_INT32 | + FieldDescriptorProto_Type::TYPE_SINT32 | + FieldDescriptorProto_Type::TYPE_SFIXED32 => format!("{}i32", proto_default), + FieldDescriptorProto_Type::TYPE_UINT32 | + FieldDescriptorProto_Type::TYPE_FIXED32 => format!("{}u32", proto_default), + FieldDescriptorProto_Type::TYPE_INT64 | + FieldDescriptorProto_Type::TYPE_SINT64 | + FieldDescriptorProto_Type::TYPE_SFIXED64 => format!("{}i64", proto_default), + FieldDescriptorProto_Type::TYPE_UINT64 | + FieldDescriptorProto_Type::TYPE_FIXED64 => format!("{}u64", proto_default), + + // For booleans, "true" or "false" + FieldDescriptorProto_Type::TYPE_BOOL => format!("{}", proto_default), + // For strings, contains the default text contents (not escaped in any way) + FieldDescriptorProto_Type::TYPE_STRING => rust::quote_escape_str(proto_default), + // For bytes, contains the C escaped value. All bytes >= 128 are escaped + FieldDescriptorProto_Type::TYPE_BYTES => rust::quote_escape_bytes( + &text_format::unescape_string(proto_default), + ), + // TODO: resolve outer message prefix + FieldDescriptorProto_Type::TYPE_GROUP | + FieldDescriptorProto_Type::TYPE_ENUM => unreachable!(), + FieldDescriptorProto_Type::TYPE_MESSAGE => { + panic!( + "default value is not implemented for type: {:?}", + self.proto_type + ) + } + }) + } else { + None + } + } + + fn default_value_from_proto_typed(&self) -> Option { + self.default_value_from_proto().map(|v| { + let default_value_type = match self.proto_type { + FieldDescriptorProto_Type::TYPE_STRING => RustType::Ref(Box::new(RustType::Str)), + FieldDescriptorProto_Type::TYPE_BYTES => { + RustType::Ref(Box::new(RustType::Slice(Box::new(RustType::u8())))) + } + _ => self.full_storage_iter_elem_type(), + }; + + RustValueTyped { + value: v, + rust_type: default_value_type, + } + }) + } + + // default value to be returned from fn get_xxx + fn get_xxx_default_value_rust(&self) -> String { + assert!(self.is_singular() || self.is_oneof()); + self.default_value_from_proto() + .unwrap_or_else(|| self.get_xxx_return_type().default_value()) + } + + // default to be assigned to field + fn element_default_value_rust(&self) -> RustValueTyped { + assert!( + self.is_singular() || self.is_oneof(), + "field is not singular: {}", + self.reconstruct_def() + ); + self.default_value_from_proto_typed() + .unwrap_or_else(|| self.elem().rust_type().default_value_typed()) + } + + pub fn reconstruct_def(&self) -> String { + let prefix = match (self.proto_field.field.get_label(), self.syntax) { + (FieldDescriptorProto_Label::LABEL_REPEATED, _) => "repeated ", + (_, Syntax::PROTO3) => "", + (FieldDescriptorProto_Label::LABEL_OPTIONAL, _) => "optional ", + (FieldDescriptorProto_Label::LABEL_REQUIRED, _) => "required ", + }; + format!( + "{}{} {} = {}", + prefix, + field_type_protobuf_name(&self.proto_field.field), + self.proto_field.name(), + self.proto_field.number() + ) + } + + pub fn accessor_fn(&self) -> AccessorFn { + match self.kind { + FieldKind::Repeated(RepeatedField { ref elem, .. }) => { + let coll = match self.full_storage_type() { + RustType::Vec(..) => "vec", + RustType::RepeatedField(..) => "repeated_field", + _ => unreachable!(), + }; + let name = format!("make_{}_accessor", coll); + AccessorFn { + name: name, + type_params: vec![elem.lib_protobuf_type()], + for_reflect_suffix: true, + accessors: vec![ + format!("get_{}_for_reflect", self.rust_name), + format!("mut_{}_for_reflect", self.rust_name), + ], + } + } + FieldKind::Map(MapField { ref key, ref value, .. }) => { + AccessorFn { + name: "make_map_accessor".to_owned(), + type_params: vec![key.lib_protobuf_type(), value.lib_protobuf_type()], + for_reflect_suffix: true, + accessors: vec![ + format!("get_{}_for_reflect", self.rust_name), + format!("mut_{}_for_reflect", self.rust_name), + ], + } + } + FieldKind::Singular(SingularField { + ref elem, + flag: SingularFieldFlag::WithoutFlag, + }) => { + if let &GenProtobufType::Message(ref name, _) = elem { + // TODO: old style, needed because of default instance + + AccessorFn { + name: "make_singular_message_accessor".to_owned(), + type_params: vec![name.clone()], + for_reflect_suffix: false, + accessors: vec![ + format!("has_{}", self.rust_name), + format!("get_{}", self.rust_name), + ], + } + } else { + AccessorFn { + name: "make_simple_field_accessor".to_owned(), + type_params: vec![elem.lib_protobuf_type()], + for_reflect_suffix: true, + accessors: vec![ + format!("get_{}_for_reflect", self.rust_name), + format!("mut_{}_for_reflect", self.rust_name), + ], + } + } + } + FieldKind::Singular(SingularField { + ref elem, + flag: SingularFieldFlag::WithFlag { .. }, + }) => { + let coll = match self.full_storage_type() { + RustType::Option(..) => "option", + RustType::SingularField(..) => "singular_field", + RustType::SingularPtrField(..) => "singular_ptr_field", + _ => unreachable!(), + }; + let name = format!("make_{}_accessor", coll); + AccessorFn { + name: name, + type_params: vec![elem.lib_protobuf_type()], + for_reflect_suffix: true, + accessors: vec![ + format!("get_{}_for_reflect", self.rust_name), + format!("mut_{}_for_reflect", self.rust_name), + ], + } + } + FieldKind::Oneof(OneofField { ref elem, .. }) => { + // TODO: uses old style + + let suffix = match &self.elem().rust_type() { + t if t.is_primitive() => format!("{}", t), + &RustType::String => "string".to_string(), + &RustType::Vec(ref t) if t.is_u8() => "bytes".to_string(), + &RustType::Enum(..) => "enum".to_string(), + &RustType::Message(..) => "message".to_string(), + t => panic!("unexpected field type: {}", t), + }; + + let name = format!("make_singular_{}_accessor", suffix); + + let mut type_params = Vec::new(); + match elem { + &GenProtobufType::Message(ref name, _) | + &GenProtobufType::Enum(ref name, _, _) => { + type_params.push(name.to_owned()); + } + _ => (), + } + + AccessorFn { + name: name, + type_params: type_params, + for_reflect_suffix: false, + accessors: vec![ + format!("has_{}", self.rust_name), + format!("get_{}", self.rust_name), + ], + } + } + } + } + + fn write_clear(&self, w: &mut CodeWriter) { + if self.is_oneof() { + w.write_line(&format!( + "self.{} = ::std::option::Option::None;", + self.oneof().oneof_name + )); + } else { + let clear_expr = self.full_storage_type().clear(&self.self_field()); + w.write_line(&format!("{};", clear_expr)); + } + } + + // expression that returns size of data is variable + fn element_size(&self, var: &str, var_type: &RustType) -> String { + assert!(!self.is_repeated_packed()); + + match field_type_size(self.proto_type) { + Some(data_size) => format!("{}", data_size + self.tag_size()), + None => { + match self.proto_type { + FieldDescriptorProto_Type::TYPE_MESSAGE => panic!("not a single-liner"), + FieldDescriptorProto_Type::TYPE_BYTES => { + format!( + "::protobuf::rt::bytes_size({}, &{})", + self.proto_field.number(), + var + ) + } + FieldDescriptorProto_Type::TYPE_STRING => { + format!( + "::protobuf::rt::string_size({}, &{})", + self.proto_field.number(), + var + ) + } + FieldDescriptorProto_Type::TYPE_ENUM => { + let param_type = match var_type { + &RustType::Ref(ref t) => (**t).clone(), + t => t.clone(), + }; + format!( + "::protobuf::rt::enum_size({}, {})", + self.proto_field.number(), + var_type.into_target(¶m_type, var) + ) + } + _ => { + let param_type = match var_type { + &RustType::Ref(ref t) => (**t).clone(), + t => t.clone(), + }; + if self.proto_type.is_s_varint() { + format!( + "::protobuf::rt::value_varint_zigzag_size({}, {})", + self.proto_field.number(), + var_type.into_target(¶m_type, var) + ) + } else { + format!( + "::protobuf::rt::value_size({}, {}, ::protobuf::wire_format::{:?})", + self.proto_field.number(), + var_type.into_target(¶m_type, var), + self.wire_type + ) + } + } + } + } + } + } + + // output code that writes single element to stream + pub fn write_write_element(&self, w: &mut CodeWriter, os: &str, var: &str, ty: &RustType) { + if let FieldKind::Repeated(RepeatedField { packed: true, .. }) = self.kind { + unreachable!(); + }; + + match self.proto_type { + FieldDescriptorProto_Type::TYPE_MESSAGE => { + w.write_line(&format!( + "{}.write_tag({}, ::protobuf::wire_format::{:?})?;", + os, + self.proto_field.number(), + wire_format::WireTypeLengthDelimited + )); + w.write_line(&format!( + "{}.write_raw_varint32({}.get_cached_size())?;", + os, + var + )); + w.write_line(&format!("{}.write_to_with_cached_sizes({})?;", var, os)); + } + _ => { + let param_type = self.os_write_fn_param_type(); + let os_write_fn_suffix = self.os_write_fn_suffix(); + let number = self.proto_field.number(); + w.write_line(&format!( + "{}.write_{}({}, {})?;", + os, + os_write_fn_suffix, + number, + ty.into_target(¶m_type, var) + )); + } + } + } + + fn self_field(&self) -> String { + format!("self.{}", self.rust_name) + } + + fn self_field_is_some(&self) -> String { + assert!(self.is_singular()); + format!("{}.is_some()", self.self_field()) + } + + fn self_field_is_not_empty(&self) -> String { + assert!(self.is_repeated_or_map()); + format!("!{}.is_empty()", self.self_field()) + } + + fn self_field_is_none(&self) -> String { + assert!(self.is_singular()); + format!("{}.is_none()", self.self_field()) + } + + // type of expression returned by `as_option()` + fn as_option_type(&self) -> RustType { + assert!(self.is_singular()); + match self.full_storage_type() { + RustType::Option(ref e) if e.is_copy() => RustType::Option(e.clone()), + RustType::Option(e) => RustType::Option(Box::new(e.ref_type())), + RustType::SingularField(ty) | + RustType::SingularPtrField(ty) => RustType::Option(Box::new(RustType::Ref(ty))), + x => panic!("cannot convert {} to option", x), + } + } + + // field data viewed as Option + fn self_field_as_option(&self) -> RustValueTyped { + assert!(self.is_singular()); + + let suffix = match self.full_storage_type() { + RustType::Option(ref e) if e.is_copy() => "", + _ => ".as_ref()", + }; + + self.as_option_type() + .value(format!("{}{}", self.self_field(), suffix)) + } + + fn write_if_let_self_field_is_some(&self, w: &mut CodeWriter, cb: F) + where + F : Fn(&str, &RustType, &mut CodeWriter), + { + match self.kind { + FieldKind::Repeated(..) | + FieldKind::Map(..) => panic!("field is not singular"), + FieldKind::Singular(SingularField { + flag: SingularFieldFlag::WithFlag { .. }, + ref elem, + }) => { + let var = "v"; + let ref_prefix = match elem.rust_type().is_copy() { + true => "", + false => "ref ", + }; + let as_option = self.self_field_as_option(); + w.if_let_stmt( + &format!("Some({}{})", ref_prefix, var), + &as_option.value, + |w| { + let v_type = as_option.rust_type.elem_type(); + cb(var, &v_type, w); + }, + ); + } + FieldKind::Singular(SingularField { + flag: SingularFieldFlag::WithoutFlag, + ref elem, + }) => { + match *elem { + GenProtobufType::Primitive(FieldDescriptorProto_Type::TYPE_STRING, ..) | + GenProtobufType::Primitive(FieldDescriptorProto_Type::TYPE_BYTES, ..) => { + w.if_stmt(format!("!{}.is_empty()", self.self_field()), |w| { + cb(&self.self_field(), &self.full_storage_type(), w); + }); + } + _ => { + w.if_stmt( + format!( + "{} != {}", + self.self_field(), + self.full_storage_type().default_value() + ), + |w| { cb(&self.self_field(), &self.full_storage_type(), w); }, + ); + } + } + } + FieldKind::Oneof(..) => unreachable!(), + } + } + + fn write_if_self_field_is_not_empty(&self, w: &mut CodeWriter, cb: F) + where + F : Fn(&mut CodeWriter), + { + assert!(self.is_repeated_or_map()); + let self_field_is_not_empty = self.self_field_is_not_empty(); + w.if_stmt(self_field_is_not_empty, cb); + } + + pub fn write_if_self_field_is_none(&self, w: &mut CodeWriter, cb: F) + where + F : Fn(&mut CodeWriter), + { + let self_field_is_none = self.self_field_is_none(); + w.if_stmt(self_field_is_none, cb) + } + + // repeated or singular + pub fn write_for_self_field(&self, w: &mut CodeWriter, varn: &str, cb: F) + where + F : Fn(&mut CodeWriter, &RustType), + { + match self.kind { + FieldKind::Oneof(OneofField { + ref elem, + ref oneof_type_name, + .. + }) => { + let cond = format!( + "Some({}::{}(ref {}))", + oneof_type_name, + self.rust_name, + varn + ); + w.if_let_stmt( + &cond, + &self.self_field_oneof(), + |w| cb(w, &elem.rust_type()), + ) + } + _ => { + let v_type = self.full_storage_iter_elem_type(); + let self_field = self.self_field(); + w.for_stmt(&format!("&{}", self_field), varn, |w| cb(w, &v_type)); + } + } + } + + fn write_self_field_assign(&self, w: &mut CodeWriter, value: &str) { + let self_field = self.self_field(); + w.write_line(&format!("{} = {};", self_field, value)); + } + + fn write_self_field_assign_some(&self, w: &mut CodeWriter, value: &str) { + let full_storage_type = self.full_storage_type(); + match self.singular() { + &SingularField { flag: SingularFieldFlag::WithFlag { .. }, .. } => { + self.write_self_field_assign(w, &full_storage_type.wrap_value(value)); + } + &SingularField { flag: SingularFieldFlag::WithoutFlag, .. } => { + self.write_self_field_assign(w, value); + } + } + } + + fn write_self_field_assign_value(&self, w: &mut CodeWriter, value: &str, ty: &RustType) { + match self.kind { + FieldKind::Repeated(..) | + FieldKind::Map(..) => { + let converted = ty.into_target(&self.full_storage_type(), value); + self.write_self_field_assign(w, &converted); + } + FieldKind::Singular(SingularField { ref elem, ref flag }) => { + let converted = ty.into_target(&elem.rust_type(), value); + let wrapped = if *flag == SingularFieldFlag::WithoutFlag { + converted + } else { + self.full_storage_type().wrap_value(&converted) + }; + self.write_self_field_assign(w, &wrapped); + } + FieldKind::Oneof(..) => unreachable!(), + } + } + + fn write_self_field_assign_default(&self, w: &mut CodeWriter) { + assert!(self.is_singular()); + if self.is_oneof() { + let self_field_oneof = self.self_field_oneof(); + w.write_line(format!( + "{} = ::std::option::Option::Some({}({}))", + self_field_oneof, + self.variant_path(), + // TODO: default from .proto is not needed here (?) + self.element_default_value_rust() + .into_type(self.full_storage_iter_elem_type()) + .value + )); + } else { + match self.full_storage_type() { + RustType::SingularField(..) | + RustType::SingularPtrField(..) => { + let self_field = self.self_field(); + w.write_line(&format!("{}.set_default();", self_field)); + } + _ => { + self.write_self_field_assign_some(w, &self.element_default_value_rust().value); + } + } + } + } + + fn self_field_vec_packed_fixed_data_size(&self) -> String { + assert!(self.is_fixed()); + format!( + "({}.len() * {}) as u32", + self.self_field(), + field_type_size(self.proto_type).unwrap() + ) + } + + fn self_field_vec_packed_varint_data_size(&self) -> String { + assert!(!self.is_fixed()); + let fn_name = if self.is_enum() { + "vec_packed_enum_data_size".to_string() + } else { + let zigzag_suffix = if self.is_zigzag() { "_zigzag" } else { "" }; + format!("vec_packed_varint{}_data_size", zigzag_suffix) + }; + format!("::protobuf::rt::{}(&{})", fn_name, self.self_field()) + } + + fn self_field_vec_packed_data_size(&self) -> String { + assert!(self.is_repeated_not_map()); + if self.is_fixed() { + self.self_field_vec_packed_fixed_data_size() + } else { + self.self_field_vec_packed_varint_data_size() + } + } + + fn self_field_vec_packed_fixed_size(&self) -> String { + // zero is filtered outside + format!( + "{} + ::protobuf::rt::compute_raw_varint32_size({}.len() as u32) + {}", + self.tag_size(), + self.self_field(), + self.self_field_vec_packed_fixed_data_size() + ) + } + + fn self_field_vec_packed_varint_size(&self) -> String { + // zero is filtered outside + assert!(!self.is_fixed()); + let fn_name = if self.is_enum() { + "vec_packed_enum_size".to_string() + } else { + let zigzag_suffix = if self.is_zigzag() { "_zigzag" } else { "" }; + format!("vec_packed_varint{}_size", zigzag_suffix) + }; + format!( + "::protobuf::rt::{}({}, &{})", + fn_name, + self.proto_field.number(), + self.self_field() + ) + } + + fn self_field_oneof(&self) -> String { + format!("self.{}", self.oneof().oneof_name) + } + + pub fn clear_field_func(&self) -> String { + format!("clear_{}", self.rust_name) + } + + + fn write_merge_from_field_message_string_bytes(&self, w: &mut CodeWriter) { + let singular_or_repeated = match self.kind { + FieldKind::Repeated(..) => "repeated", + FieldKind::Map(..) => "repeated", // TODO + FieldKind::Singular(SingularField { flag: SingularFieldFlag::WithFlag { .. }, .. }) => { + "singular" + } + FieldKind::Singular(SingularField { flag: SingularFieldFlag::WithoutFlag, .. }) => { + "singular_proto3" + } + FieldKind::Oneof(..) => unreachable!(), + }; + let carllerche = match self.kind.primitive_type_variant() { + PrimitiveTypeVariant::Carllerche => "carllerche_", + PrimitiveTypeVariant::Default => "", + }; + let type_name_for_fn = protobuf_name(self.proto_type); + w.write_line(&format!( + "::protobuf::rt::read_{}_{}{}_into(wire_type, is, &mut self.{})?;", + singular_or_repeated, + carllerche, + type_name_for_fn, + self.rust_name + )); + } + + fn write_merge_from_oneof(&self, f: &OneofField, w: &mut CodeWriter) { + w.assert_wire_type(self.wire_type); + + let typed = RustValueTyped { + value: format!("{}?", self.proto_type.read("is")), + rust_type: self.full_storage_iter_elem_type(), + }; + + let maybe_boxed = if f.boxed { typed.boxed() } else { typed }; + + w.write_line(&format!( + "self.{} = ::std::option::Option::Some({}({}));", + self.oneof().oneof_name, + self.variant_path(), + maybe_boxed.value + )); // TODO: into_type + } + + fn write_merge_from_map(&self, w: &mut CodeWriter) { + let &MapField { ref key, ref value, .. } = self.map(); + w.write_line(&format!( + "::protobuf::rt::read_map_into::<{}, {}>(wire_type, is, &mut {})?;", + key.lib_protobuf_type(), + value.lib_protobuf_type(), + self.self_field() + )); + } + + pub fn write_merge_from_field(&self, w: &mut CodeWriter) { + match self.kind { + FieldKind::Oneof(ref f) => self.write_merge_from_oneof(&f, w), + FieldKind::Map(..) => self.write_merge_from_map(w), + _ => { + if !self.elem_type_is_copy() { + self.write_merge_from_field_message_string_bytes(w); + } else { + let wire_type = field_type_wire_type(self.proto_type); + let read_proc = format!("is.read_{}()?", protobuf_name(self.proto_type)); + + match self.kind { + FieldKind::Singular(..) => { + w.assert_wire_type(wire_type); + w.write_line(&format!("let tmp = {};", read_proc)); + self.write_self_field_assign_some(w, "tmp"); + } + FieldKind::Repeated(..) => { + w.write_line(&format!( + "::protobuf::rt::read_repeated_{}_into(wire_type, is, &mut self.{})?;", + protobuf_name(self.proto_type), + self.rust_name)); + } + _ => unreachable!(), + } + } + } + } + } + + fn self_field_vec_packed_size(&self) -> String { + match self.kind { + FieldKind::Repeated(RepeatedField { packed: true, .. }) => { + // zero is filtered outside + if self.is_fixed() { + self.self_field_vec_packed_fixed_size() + } else { + self.self_field_vec_packed_varint_size() + } + } + _ => { + panic!("not packed"); + } + } + } + + pub fn write_element_size( + &self, + w: &mut CodeWriter, + item_var: &str, + item_var_type: &RustType, + sum_var: &str, + ) { + assert!(!self.is_repeated_packed()); + + match self.proto_type { + FieldDescriptorProto_Type::TYPE_MESSAGE => { + w.write_line(&format!("let len = {}.compute_size();", item_var)); + let tag_size = self.tag_size(); + w.write_line(&format!( + "{} += {} + ::protobuf::rt::compute_raw_varint32_size(len) + len;", + sum_var, + tag_size + )); + } + _ => { + w.write_line(&format!( + "{} += {};", + sum_var, + self.element_size(item_var, item_var_type) + )); + } + } + } + + pub fn write_message_write_field(&self, w: &mut CodeWriter) { + match self.kind { + FieldKind::Singular(..) => { + self.write_if_let_self_field_is_some(w, |v, v_type, w| { + self.write_write_element(w, "os", v, v_type); + }); + } + FieldKind::Repeated(RepeatedField { packed: false, .. }) => { + self.write_for_self_field(w, "v", |w, v_type| { + self.write_write_element(w, "os", "v", v_type); + }); + } + FieldKind::Repeated(RepeatedField { packed: true, .. }) => { + self.write_if_self_field_is_not_empty(w, |w| { + let number = self.proto_field.number(); + w.write_line(&format!( + "os.write_tag({}, ::protobuf::wire_format::{:?})?;", + number, + wire_format::WireTypeLengthDelimited + )); + w.comment("TODO: Data size is computed again, it should be cached"); + let data_size_expr = self.self_field_vec_packed_data_size(); + w.write_line(&format!("os.write_raw_varint32({})?;", data_size_expr)); + self.write_for_self_field(w, "v", |w, v_type| { + let param_type = self.os_write_fn_param_type(); + let os_write_fn_suffix = self.os_write_fn_suffix(); + w.write_line(&format!( + "os.write_{}_no_tag({})?;", + os_write_fn_suffix, + v_type.into_target(¶m_type, "v") + )); + }); + }); + } + FieldKind::Map(MapField { ref key, ref value, .. }) => { + w.write_line(&format!( + "::protobuf::rt::write_map_with_cached_sizes::<{}, {}>({}, &{}, os)?;", + key.lib_protobuf_type(), + value.lib_protobuf_type(), + self.proto_field.number(), + self.self_field() + )); + } + FieldKind::Oneof(..) => unreachable!(), + }; + } + + pub fn write_message_compute_field_size(&self, sum_var: &str, w: &mut CodeWriter) { + match self.kind { + FieldKind::Singular(..) => { + self.write_if_let_self_field_is_some(w, |v, v_type, w| { + match field_type_size(self.proto_type) { + Some(s) => { + let tag_size = self.tag_size(); + w.write_line(&format!("{} += {};", sum_var, (s + tag_size) as isize)); + } + None => { + self.write_element_size(w, v, v_type, sum_var); + } + }; + }); + } + FieldKind::Repeated(RepeatedField { packed: false, .. }) => { + match field_type_size(self.proto_type) { + Some(s) => { + let tag_size = self.tag_size(); + let self_field = self.self_field(); + w.write_line(&format!( + "{} += {} * {}.len() as u32;", + sum_var, + (s + tag_size) as isize, + self_field + )); + } + None => { + self.write_for_self_field(w, "value", |w, value_type| { + self.write_element_size(w, "value", value_type, sum_var); + }); + } + }; + } + FieldKind::Map(MapField { ref key, ref value, .. }) => { + w.write_line(&format!( + "{} += ::protobuf::rt::compute_map_size::<{}, {}>({}, &{});", + sum_var, + key.lib_protobuf_type(), + value.lib_protobuf_type(), + self.proto_field.number(), + self.self_field() + )); + } + FieldKind::Repeated(RepeatedField { packed: true, .. }) => { + self.write_if_self_field_is_not_empty(w, |w| { + let size_expr = self.self_field_vec_packed_size(); + w.write_line(&format!("{} += {};", sum_var, size_expr)); + }); + } + FieldKind::Oneof(..) => unreachable!(), + } + } + + fn write_message_field_get_singular(&self, w: &mut CodeWriter) { + let get_xxx_return_type = self.get_xxx_return_type(); + + if self.proto_type == FieldDescriptorProto_Type::TYPE_MESSAGE { + let self_field = self.self_field(); + let ref field_type_name = self.elem().rust_type(); + w.write_line(&format!( + "{}.as_ref().unwrap_or_else(|| {}::default_instance())", + self_field, + field_type_name + )); + } else { + let get_xxx_default_value_rust = self.get_xxx_default_value_rust(); + let self_field = self.self_field(); + match self.singular() { + &SingularField { flag: SingularFieldFlag::WithFlag { .. }, .. } => { + if get_xxx_return_type.is_ref() { + let as_option = self.self_field_as_option(); + w.match_expr(&as_option.value, |w| { + let v_type = as_option.rust_type.elem_type(); + let r_type = self.get_xxx_return_type(); + w.case_expr("Some(v)", v_type.into_target(&r_type, "v")); + let get_xxx_default_value_rust = self.get_xxx_default_value_rust(); + w.case_expr("None", get_xxx_default_value_rust); + }); + } else { + w.write_line(&format!( + "{}.unwrap_or({})", + self_field, + get_xxx_default_value_rust + )); + } + } + &SingularField { flag: SingularFieldFlag::WithoutFlag, .. } => { + w.write_line( + self.full_storage_type() + .into_target(&get_xxx_return_type, &self_field), + ); + } + } + } + } + + fn write_message_field_get(&self, w: &mut CodeWriter) { + let get_xxx_return_type = self.get_xxx_return_type(); + let fn_def = format!("get_{}(&self) -> {}", self.rust_name, get_xxx_return_type); + + w.pub_fn(&fn_def, |w| match self.kind { + FieldKind::Oneof(OneofField { ref elem, .. }) => { + let self_field_oneof = self.self_field_oneof(); + w.match_expr(self_field_oneof, |w| { + let (refv, vtype) = if !self.elem_type_is_copy() { + ("ref v", elem.rust_type().ref_type()) + } else { + ("v", elem.rust_type()) + }; + w.case_expr( + format!( + "::std::option::Option::Some({}({}))", + self.variant_path(), + refv + ), + vtype.into_target(&get_xxx_return_type, "v"), + ); + w.case_expr("_", self.get_xxx_default_value_rust()); + }) + } + FieldKind::Singular(..) => { + self.write_message_field_get_singular(w); + } + FieldKind::Repeated(..) | + FieldKind::Map(..) => { + let self_field = self.self_field(); + w.write_line(&format!("&{}", self_field)); + } + }); + } + + fn write_message_field_get_for_reflect(&self, w: &mut CodeWriter) { + let sig = format!( + "get_{}_for_reflect(&self) -> &{}", + self.rust_name, + self.full_storage_type() + ); + w.def_fn(&sig, |w| w.write_line(&format!("&{}", self.self_field()))); + } + + fn write_message_field_mut_for_reflect(&self, w: &mut CodeWriter) { + let sig = format!( + "mut_{}_for_reflect(&mut self) -> &mut {}", + self.rust_name, + self.full_storage_type() + ); + w.def_fn( + &sig, + |w| w.write_line(&format!("&mut {}", self.self_field())), + ); + } + + fn has_has(&self) -> bool { + match self.kind { + FieldKind::Repeated(..) | + FieldKind::Map(..) => false, + FieldKind::Singular(SingularField { flag: SingularFieldFlag::WithFlag { .. }, .. }) => { + true + } + FieldKind::Singular(SingularField { flag: SingularFieldFlag::WithoutFlag, .. }) => { + false + } + FieldKind::Oneof(..) => true, + } + } + + fn has_mut(&self) -> bool { + match self.kind { + FieldKind::Repeated(..) | + FieldKind::Map(..) => true, + // TODO: string should be public, and mut is not needed + FieldKind::Singular(..) | + FieldKind::Oneof(..) => !self.elem_type_is_copy(), + } + } + + fn has_take(&self) -> bool { + match self.kind { + FieldKind::Repeated(..) | + FieldKind::Map(..) => true, + // TODO: string should be public, and mut is not needed + FieldKind::Singular(..) | + FieldKind::Oneof(..) => !self.elem_type_is_copy(), + } + + } + + fn has_name(&self) -> String { + format!("has_{}", self.rust_name) + } + + fn write_message_field_has(&self, w: &mut CodeWriter) { + w.pub_fn(&format!("{}(&self) -> bool", self.has_name()), |w| { + if !self.is_oneof() { + let self_field_is_some = self.self_field_is_some(); + w.write_line(self_field_is_some); + } else { + let self_field_oneof = self.self_field_oneof(); + w.match_expr(self_field_oneof, |w| { + w.case_expr( + format!("::std::option::Option::Some({}(..))", self.variant_path()), + "true", + ); + w.case_expr("_", "false"); + }); + } + }); + } + + fn write_message_field_set(&self, w: &mut CodeWriter) { + let set_xxx_param_type = self.set_xxx_param_type(); + w.comment("Param is passed by value, moved"); + let ref name = self.rust_name; + w.pub_fn(&format!("set_{}(&mut self, v: {})", name, set_xxx_param_type), |w| { + if !self.is_oneof() { + self.write_self_field_assign_value(w, "v", &set_xxx_param_type); + } else { + let self_field_oneof = self.self_field_oneof(); + let v = set_xxx_param_type.into_target(&self.oneof().rust_type(), "v"); + w.write_line(&format!("{} = ::std::option::Option::Some({}({}))", + self_field_oneof, self.variant_path(), v)); + } + }); + } + + fn write_message_field_mut(&self, w: &mut CodeWriter) { + let mut_xxx_return_type = self.mut_xxx_return_type(); + w.comment("Mutable pointer to the field."); + if self.is_singular() { + w.comment( + "If field is not initialized, it is initialized with default value first.", + ); + } + let fn_def = match mut_xxx_return_type { + RustType::Ref(ref param) => { + format!("mut_{}(&mut self) -> &mut {}", self.rust_name, **param) + } + _ => panic!("not a ref: {}", mut_xxx_return_type), + }; + w.pub_fn(&fn_def, |w| { + match self.kind { + FieldKind::Repeated(..) | + FieldKind::Map(..) => { + let self_field = self.self_field(); + w.write_line(&format!("&mut {}", self_field)); + } + FieldKind::Singular( + SingularField { flag: SingularFieldFlag::WithFlag { .. }, .. }, + ) => { + self.write_if_self_field_is_none( + w, + |w| { self.write_self_field_assign_default(w); }, + ); + let self_field = self.self_field(); + w.write_line(&format!("{}.as_mut().unwrap()", self_field)); + } + FieldKind::Singular(SingularField { flag: SingularFieldFlag::WithoutFlag, .. }) => { + w.write_line(&format!("&mut {}", self.self_field())) + } + FieldKind::Oneof(..) => { + let self_field_oneof = self.self_field_oneof(); + + // if oneof does not contain current field + w.if_let_else_stmt(&format!( + "::std::option::Option::Some({}(_))", + self.variant_path())[..], &self_field_oneof[..], + |w| + { + // initialize it with default value + w.write_line(&format!( + "{} = ::std::option::Option::Some({}({}));", + self_field_oneof, + self.variant_path(), + self.element_default_value_rust() + .into_type(self.oneof().rust_type()) + .value)); + }); + + // extract field + w.match_expr(self_field_oneof, |w| { + w.case_expr( + format!( + "::std::option::Option::Some({}(ref mut v))", + self.variant_path() + ), + "v", + ); + w.case_expr("_", "panic!()"); + }); + } + } + }); + } + + fn write_message_field_take_oneof(&self, w: &mut CodeWriter) { + let take_xxx_return_type = self.take_xxx_return_type(); + + // TODO: replace with if let + w.write_line(&format!("if self.{}() {{", self.has_name())); + w.indented(|w| { + let self_field_oneof = self.self_field_oneof(); + w.match_expr(format!("{}.take()", self_field_oneof), |w| { + let value_in_some = self.oneof().rust_type().value("v".to_owned()); + let converted = value_in_some.into_type(self.take_xxx_return_type()); + w.case_expr( + format!("::std::option::Option::Some({}(v))", self.variant_path()), + &converted.value, + ); + w.case_expr("_", "panic!()"); + }); + }); + w.write_line("} else {"); + w.indented(|w| { + w.write_line( + self.elem() + .rust_type() + .default_value_typed() + .into_type(take_xxx_return_type.clone()) + .value, + ); + }); + w.write_line("}"); + } + + fn write_message_field_take(&self, w: &mut CodeWriter) { + let take_xxx_return_type = self.take_xxx_return_type(); + w.comment("Take field"); + w.pub_fn( + &format!( + "take_{}(&mut self) -> {}", + self.rust_name, + take_xxx_return_type + ), + |w| match self.kind { + FieldKind::Oneof(..) => { + self.write_message_field_take_oneof(w); + } + FieldKind::Repeated(..) | + FieldKind::Map(..) => { + w.write_line(&format!( + "::std::mem::replace(&mut self.{}, {})", + self.rust_name, + take_xxx_return_type.default_value() + )); + + } + FieldKind::Singular(SingularField { + ref elem, + flag: SingularFieldFlag::WithFlag { .. }, + }) => { + if !elem.is_copy() { + w.write_line(&format!( + "{}.take().unwrap_or_else(|| {})", + self.self_field(), + elem.rust_type().default_value() + )); + } else { + w.write_line(&format!( + "{}.take().unwrap_or({})", + self.self_field(), + self.element_default_value_rust().value + )); + } + } + FieldKind::Singular(SingularField { flag: SingularFieldFlag::WithoutFlag, .. }) => { + w.write_line(&format!( + "::std::mem::replace(&mut {}, {})", + self.self_field(), + self.full_storage_type().default_value() + )) + } + }, + ); + } + + pub fn write_message_single_field_accessors(&self, w: &mut CodeWriter) { + let clear_field_func = self.clear_field_func(); + w.pub_fn(&format!("{}(&mut self)", clear_field_func), |w| { + self.write_clear(w); + }); + + if self.has_has() { + w.write_line(""); + self.write_message_field_has(w); + } + + w.write_line(""); + self.write_message_field_set(w); + + if self.has_mut() { + w.write_line(""); + self.write_message_field_mut(w); + } + + if self.has_take() { + w.write_line(""); + self.write_message_field_take(w); + } + + w.write_line(""); + self.write_message_field_get(w); + + if self.accessor_fn().for_reflect_suffix { + w.write_line(""); + self.write_message_field_get_for_reflect(w); + w.write_line(""); + self.write_message_field_mut_for_reflect(w); + } + } +} + +#[derive(Clone)] +pub struct OneofVariantGen<'a> { + oneof: &'a OneofGen<'a>, + variant: OneofVariantWithContext<'a>, + oneof_field: OneofField, + pub field: FieldGen<'a>, + path: String, +} + +impl<'a> OneofVariantGen<'a> { + fn parse( + oneof: &'a OneofGen<'a>, + variant: OneofVariantWithContext<'a>, + field: &'a FieldGen, + ) -> OneofVariantGen<'a> { + OneofVariantGen { + oneof: oneof, + variant: variant.clone(), + field: field.clone(), + path: format!("{}::{}", oneof.type_name, field.rust_name), + oneof_field: OneofField::parse( + variant.oneof, + variant.field, + field.oneof().elem.clone(), + ), + } + } + + fn rust_type(&self) -> RustType { + self.oneof_field.rust_type() + } + + pub fn path(&self) -> String { + self.path.clone() + } +} + +#[derive(Clone)] +pub struct OneofGen<'a> { + // Message containing this oneof + message: &'a MessageGen<'a>, + oneof: OneofWithContext<'a>, + type_name: RustType, + lite_runtime: bool, +} + +impl<'a> OneofGen<'a> { + pub fn parse(message: &'a MessageGen, oneof: OneofWithContext<'a>) -> OneofGen<'a> { + let rust_name = oneof.rust_name(); + OneofGen { + message: message, + oneof: oneof, + type_name: RustType::Oneof(rust_name), + lite_runtime: message.lite_runtime, + } + } + + pub fn name(&self) -> &str { + match self.oneof.oneof.get_name() { + "type" => "field_type", + "box" => "field_box", + x => x, + } + } + + pub fn variants(&'a self) -> Vec> { + self.oneof + .variants() + .into_iter() + .map(|v| { + let field = self.message + .fields + .iter() + .filter(|f| f.proto_field.name() == v.field.get_name()) + .next() + .expect(&format!("field not found by name: {}", v.field.get_name())); + OneofVariantGen::parse(self, v, field) + }) + .collect() + } + + pub fn full_storage_type(&self) -> RustType { + RustType::Option(Box::new(self.type_name.clone())) + } + + pub fn write_enum(&self, w: &mut CodeWriter) { + let mut derive = vec!["Clone", "PartialEq"]; + if self.lite_runtime { + derive.push("Debug"); + } + w.derive(&derive); + w.pub_enum(&self.type_name.to_string(), |w| { + for variant in self.variants() { + w.write_line(&format!( + "{}({}),", + variant.field.rust_name, + &variant.rust_type().to_string() + )); + } + }); + } +} diff --git a/third_party/protobuf/src/codegen/message.rs b/third_party/protobuf/src/codegen/message.rs new file mode 100644 index 000000000..f4f822410 --- /dev/null +++ b/third_party/protobuf/src/codegen/message.rs @@ -0,0 +1,473 @@ +use descriptor::*; +use descriptorx::*; +use code_writer::*; +use rustproto; + +use super::enums::*; +use super::rust_types_values::*; +use super::field::*; + + + +/// Message info for codegen +pub struct MessageGen<'a> { + message: &'a MessageWithScope<'a>, + root_scope: &'a RootScope<'a>, + type_name: String, + pub fields: Vec>, + pub lite_runtime: bool, +} + +impl<'a> MessageGen<'a> { + pub fn new(message: &'a MessageWithScope<'a>, root_scope: &'a RootScope<'a>) -> MessageGen<'a> { + let fields: Vec<_> = message + .fields() + .into_iter() + .map(|field| FieldGen::parse(field, root_scope)) + .collect(); + MessageGen { + message: message, + root_scope: root_scope, + type_name: message.rust_name(), + fields: fields, + lite_runtime: message + .get_file_descriptor() + .get_options() + .get_optimize_for() == + FileOptions_OptimizeMode::LITE_RUNTIME, + } + } + + fn expose_oneof(&self) -> bool { + let options = self.message.get_scope().get_file_descriptor().get_options(); + rustproto::exts::expose_oneof_all + .get(options) + .unwrap_or(false) + } + + fn oneofs(&'a self) -> Vec> { + self.message + .oneofs() + .into_iter() + .map(|oneof| OneofGen::parse(self, oneof)) + .collect() + } + + fn required_fields(&'a self) -> Vec<&'a FieldGen> { + self.fields + .iter() + .filter(|f| match f.kind { + FieldKind::Singular(ref singular) => singular.flag.is_required(), + _ => false, + }) + .collect() + } + + fn message_fields(&'a self) -> Vec<&'a FieldGen> { + self.fields + .iter() + .filter(|f| f.proto_type == FieldDescriptorProto_Type::TYPE_MESSAGE) + .collect() + } + + fn fields_except_oneof(&'a self) -> Vec<&'a FieldGen> { + self.fields + .iter() + .filter(|f| !f.is_oneof()) + .collect() + } + + fn fields_except_group(&'a self) -> Vec<&'a FieldGen> { + self.fields + .iter() + .filter(|f| f.proto_type != FieldDescriptorProto_Type::TYPE_GROUP) + .collect() + } + + fn fields_except_oneof_and_group(&'a self) -> Vec<&'a FieldGen> { + self.fields + .iter() + .filter(|f| { + !f.is_oneof() && f.proto_type != FieldDescriptorProto_Type::TYPE_GROUP + }) + .collect() + } + + + fn write_match_each_oneof_variant(&self, w: &mut CodeWriter, cb: F) + where + F : Fn(&mut CodeWriter, &OneofVariantGen, &str, &RustType), + { + for oneof in self.oneofs() { + w.if_let_stmt("::std::option::Option::Some(ref v)", &format!("self.{}", oneof.name())[..], |w| { + w.match_block("v", |w| { + for variant in oneof.variants() { + let ref field = variant.field; + let (refv, vtype) = + if !field.elem_type_is_copy() { + ("ref v", field.elem().rust_type().ref_type()) + } else { + ("v", field.elem().rust_type()) + }; + w.case_block(format!("&{}({})", variant.path(), refv), |w| { + cb(w, &variant, "v", &vtype); + }); + } + }); + }); + } + } + + fn write_write_to_with_cached_sizes(&self, w: &mut CodeWriter) { + w.def_fn("write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()>", |w| { + // To have access to its methods but not polute the name space. + for f in self.fields_except_oneof_and_group() { + f.write_message_write_field(w); + } + self.write_match_each_oneof_variant(w, |w, variant, v, v_type| { + variant.field.write_write_element(w, "os", v, v_type); + }); + w.write_line("os.write_unknown_fields(self.get_unknown_fields())?;"); + w.write_line("::std::result::Result::Ok(())"); + }); + } + + fn write_get_cached_size(&self, w: &mut CodeWriter) { + w.def_fn("get_cached_size(&self) -> u32", |w| { + w.write_line("self.cached_size.get()"); + }); + } + + fn write_default_instance(&self, w: &mut CodeWriter) { + w.pub_fn(&format!("default_instance() -> &'static {}", self.type_name), |w| { + w.lazy_static_decl_get_simple( + "instance", + &self.type_name, + &format!("{}::new", self.type_name)); + }); + } + + fn write_compute_size(&self, w: &mut CodeWriter) { + // Append sizes of messages in the tree to the specified vector. + // First appended element is size of self, and then nested message sizes. + // in serialization order are appended recursively."); + w.comment("Compute sizes of nested messages"); + // there are unused variables in oneof + w.allow(&["unused_variables"]); + w.def_fn("compute_size(&self) -> u32", |w| { + // To have access to its methods but not polute the name space. + w.write_line("let mut my_size = 0;"); + for field in self.fields_except_oneof_and_group() { + field.write_message_compute_field_size("my_size", w); + } + self.write_match_each_oneof_variant(w, |w, variant, v, vtype| { + variant.field.write_element_size(w, v, vtype, "my_size"); + }); + w.write_line( + "my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());", + ); + w.write_line("self.cached_size.set(my_size);"); + w.write_line("my_size"); + }); + } + + fn write_field_accessors(&self, w: &mut CodeWriter) { + for f in self.fields_except_group() { + w.write_line(""); + let reconstruct_def = f.reconstruct_def(); + w.comment(&(reconstruct_def + ";")); + w.write_line(""); + f.write_message_single_field_accessors(w); + } + } + + fn write_impl_self(&self, w: &mut CodeWriter) { + w.impl_self_block(&self.type_name, |w| { + w.pub_fn(&format!("new() -> {}", self.type_name), |w| { + w.write_line("::std::default::Default::default()"); + }); + + w.write_line(""); + self.write_default_instance(w); + self.write_field_accessors(w); + }); + } + + fn write_unknown_fields(&self, w: &mut CodeWriter) { + w.def_fn( + "get_unknown_fields(&self) -> &::protobuf::UnknownFields", + |w| { w.write_line("&self.unknown_fields"); }, + ); + w.write_line(""); + w.def_fn("mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields", |w| { + w.write_line("&mut self.unknown_fields"); + }); + } + + fn write_merge_from(&self, w: &mut CodeWriter) { + w.def_fn(&format!("merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()>"), |w| { + w.while_block("!is.eof()?", |w| { + w.write_line(&format!("let (field_number, wire_type) = is.read_tag_unpack()?;")); + w.match_block("field_number", |w| { + for f in &self.fields_except_group() { + let number = f.proto_field.number(); + w.case_block(number.to_string(), |w| { + f.write_merge_from_field(w); + }); + } + w.case_block("_", |w| { + w.write_line("::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;"); + }); + }); + }); + w.write_line("::std::result::Result::Ok(())"); + }); + } + + fn write_descriptor_field(&self, fields_var: &str, field: &FieldGen, w: &mut CodeWriter) { + let accessor_fn = field.accessor_fn(); + w.write_line(&format!( + "{}.push(::protobuf::reflect::accessor::{}(", + fields_var, + accessor_fn.sig() + )); + w.indented(|w| { + w.write_line(&format!("\"{}\",", field.proto_field.name())); + for acc in &accessor_fn.accessors { + w.write_line(&format!("{}::{},", self.type_name, acc)); + } + }); + w.write_line("));"); + } + + fn write_descriptor_static(&self, w: &mut CodeWriter) { + w.def_fn(&format!("descriptor_static(_: ::std::option::Option<{}>) -> &'static ::protobuf::reflect::MessageDescriptor", self.type_name), |w| { + w.lazy_static_decl_get("descriptor", "::protobuf::reflect::MessageDescriptor", |w| { + let fields = self.fields_except_group(); + if fields.is_empty() { + w.write_line(&format!("let fields = ::std::vec::Vec::new();")); + } else { + w.write_line(&format!("let mut fields = ::std::vec::Vec::new();")); + } + for field in fields { + self.write_descriptor_field("fields", field, w);; + } + w.write_line(&format!( + "::protobuf::reflect::MessageDescriptor::new::<{}>(", self.type_name)); + w.indented(|w| { + w.write_line(&format!("\"{}\",", self.type_name)); + w.write_line("fields,"); + w.write_line("file_descriptor_proto()"); + }); + w.write_line(")"); + }); + }); + } + + fn write_is_initialized(&self, w: &mut CodeWriter) { + w.def_fn(&format!("is_initialized(&self) -> bool"), |w| { + // TODO: use single loop + + for f in self.required_fields() { + f.write_if_self_field_is_none(w, |w| { w.write_line("return false;"); }); + } + + for f in self.message_fields() { + if let FieldKind::Map(..) = f.kind { + // TODO: check values + continue; + } + + // TODO: + // if message is declared in this file and has no message fields, + // we could skip the check here + f.write_for_self_field(w, "v", |w, _t| { + w.if_stmt( + "!v.is_initialized()", + |w| { w.write_line("return false;"); }, + ); + }); + } + w.write_line("true"); + }); + } + + fn write_impl_message(&self, w: &mut CodeWriter) { + w.impl_for_block("::protobuf::Message", &self.type_name, |w| { + self.write_is_initialized(w); + w.write_line(""); + self.write_merge_from(w); + w.write_line(""); + self.write_compute_size(w); + w.write_line(""); + self.write_write_to_with_cached_sizes(w); + w.write_line(""); + self.write_get_cached_size(w); + w.write_line(""); + self.write_unknown_fields(w); + w.write_line(""); + w.def_fn("as_any(&self) -> &::std::any::Any", |w| { + w.write_line("self as &::std::any::Any"); + }); + w.def_fn("as_any_mut(&mut self) -> &mut ::std::any::Any", |w| { + w.write_line("self as &mut ::std::any::Any"); + }); + w.def_fn("into_any(self: Box) -> ::std::boxed::Box<::std::any::Any>", |w| { + w.write_line("self"); + }); + w.write_line(""); + w.def_fn("descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor", |w| { + w.write_line("::protobuf::MessageStatic::descriptor_static(None::)"); + }); + }); + } + + fn write_impl_message_static(&self, w: &mut CodeWriter) { + w.impl_for_block("::protobuf::MessageStatic", &self.type_name, |w| { + w.def_fn(&format!("new() -> {}", self.type_name), |w| { + w.write_line(&format!("{}::new()", self.type_name)); + }); + if !self.lite_runtime { + w.write_line(""); + self.write_descriptor_static(w); + } + }); + } + + fn write_impl_value(&self, w: &mut CodeWriter) { + w.impl_for_block("::protobuf::reflect::ProtobufValue", &self.type_name, |w| { + w.def_fn( + "as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef", + |w| w.write_line("::protobuf::reflect::ProtobufValueRef::Message(self)"), + ) + }) + } + + fn write_impl_show(&self, w: &mut CodeWriter) { + w.impl_for_block("::std::fmt::Debug", &self.type_name, |w| { + w.def_fn("fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result", |w| { + w.write_line("::protobuf::text_format::fmt(self, f)"); + }); + }); + } + + fn write_impl_clear(&self, w: &mut CodeWriter) { + w.impl_for_block("::protobuf::Clear", &self.type_name, |w| { + w.def_fn("clear(&mut self)", |w| { + // TODO: no need to clear oneof fields in loop + for f in self.fields_except_group() { + let clear_field_func = f.clear_field_func(); + w.write_line(&format!("self.{}();", clear_field_func)); + } + w.write_line("self.unknown_fields.clear();"); + }); + }); + } + + fn write_struct(&self, w: &mut CodeWriter) { + let mut derive = vec!["PartialEq", "Clone", "Default"]; + if self.lite_runtime { + derive.push("Debug"); + } + w.derive(&derive); + w.pub_struct(&self.type_name, |w| { + if !self.fields_except_oneof().is_empty() { + w.comment("message fields"); + for field in self.fields_except_oneof() { + if field.proto_type == FieldDescriptorProto_Type::TYPE_GROUP { + w.comment(&format!("{}: ", &field.rust_name)); + } else { + let vis = if field.expose_field { + Visibility::Public + } else { + match field.kind { + FieldKind::Repeated(..) => Visibility::Default, + FieldKind::Singular(SingularField { ref flag, .. }) => { + match *flag { + SingularFieldFlag::WithFlag { .. } => Visibility::Default, + SingularFieldFlag::WithoutFlag => Visibility::Public, + } + } + FieldKind::Map(..) => Visibility::Public, + FieldKind::Oneof(..) => unreachable!(), + } + }; + w.field_decl_vis( + vis, + &field.rust_name, + &field.full_storage_type().to_string(), + ); + } + } + } + if !self.oneofs().is_empty() { + w.comment("message oneof groups"); + for oneof in self.oneofs() { + let vis = match self.expose_oneof() { + true => Visibility::Public, + false => Visibility::Default, + }; + w.field_decl_vis(vis, oneof.name(), &oneof.full_storage_type().to_string()); + } + } + w.comment("special fields"); + // TODO: make public + w.field_decl("unknown_fields", "::protobuf::UnknownFields"); + w.field_decl("cached_size", "::protobuf::CachedSize"); + }); + } + + pub fn write(&self, w: &mut CodeWriter) { + self.write_struct(w); + + // Cell (which stores cached size) is not Sync + // so messages do not implicitly implement sync. + // `cached_size` could be of type `AtomicUsize`, which could be updated + // with `Ordering::Relaxed`, however: + // * usize is twice as large as u32 on 64-bit, and rust has no `AtomicU32` + // * there's small performance degradation when using `AtomicUsize`, which is + // probably related to https://github.com/rust-lang/rust/pull/30962 + // Anyway, `cached_size` is always read after updated from the same thread + // so even in theory the code is incorrect, `u32` write is atomic on all platforms. + w.write_line(""); + w.comment( + "see codegen.rs for the explanation why impl Sync explicitly", + ); + w.unsafe_impl("::std::marker::Sync", &self.type_name); + for oneof in self.oneofs() { + w.write_line(""); + oneof.write_enum(w); + } + + w.write_line(""); + self.write_impl_self(w); + w.write_line(""); + self.write_impl_message(w); + w.write_line(""); + self.write_impl_message_static(w); + w.write_line(""); + self.write_impl_clear(w); + if !self.lite_runtime { + w.write_line(""); + self.write_impl_show(w); + } + w.write_line(""); + self.write_impl_value(w); + + let mut nested_prefix = self.type_name.to_string(); + nested_prefix.push_str("_"); + + for nested in &self.message.to_scope().get_messages() { + // ignore map entries, because they are not used in map fields + if nested.map_entry().is_none() { + w.write_line(""); + MessageGen::new(nested, self.root_scope).write(w); + } + } + + for enum_type in &self.message.to_scope().get_enums() { + w.write_line(""); + EnumGen::new(enum_type, self.message.get_scope().get_file_descriptor()).write(w); + } + } +} diff --git a/third_party/protobuf/src/codegen/mod.rs b/third_party/protobuf/src/codegen/mod.rs new file mode 100644 index 000000000..7120e9b66 --- /dev/null +++ b/third_party/protobuf/src/codegen/mod.rs @@ -0,0 +1,171 @@ +use std::collections::hash_map::HashMap; +use std::fmt::Write; + +use descriptor::*; +use protocore::Message; +use compiler_plugin; +use code_writer::CodeWriter; +use descriptorx::*; + +mod message; +mod enums; +mod rust_types_values; +mod well_known_types; +mod field; +mod extensions; + +use self::message::*; +use self::enums::*; +use self::extensions::*; + + +fn escape_byte(s: &mut String, b: u8) { + if b == b'\n' { + write!(s, "\\n").unwrap(); + } else if b == b'\r' { + write!(s, "\\r").unwrap(); + } else if b == b'\t' { + write!(s, "\\t").unwrap(); + } else if b == b'\\' || b == b'"' { + write!(s, "\\{}", b as char).unwrap(); + } else if b == b'\0' { + write!(s, "\\0").unwrap(); + // ASCII printable except space + } else if b > 0x20 && b < 0x7f { + write!(s, "{}", b as char).unwrap(); + } else { + write!(s, "\\x{:02x}", b).unwrap(); + } +} + +fn write_file_descriptor_data(file: &FileDescriptorProto, w: &mut CodeWriter) { + let fdp_bytes = file.write_to_bytes().unwrap(); + w.write_line("static file_descriptor_proto_data: &'static [u8] = b\"\\"); + w.indented(|w| { + const MAX_LINE_LEN: usize = 72; + + let mut s = String::new(); + for &b in &fdp_bytes { + let prev_len = s.len(); + escape_byte(&mut s, b); + let truncate = s.len() > MAX_LINE_LEN; + if truncate { + s.truncate(prev_len); + } + if truncate || s.len() == MAX_LINE_LEN { + write!(s, "\\").unwrap(); + w.write_line(&s); + s.clear(); + } + if truncate { + escape_byte(&mut s, b); + } + } + if !s.is_empty() { + write!(s, "\\").unwrap(); + w.write_line(&s); + s.clear(); + } + }); + w.write_line("\";"); + w.write_line(""); + w.lazy_static( + "file_descriptor_proto_lazy", + "::protobuf::descriptor::FileDescriptorProto", + ); + w.write_line(""); + w.def_fn("parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto", |w| { + w.write_line("::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap()"); + }); + w.write_line(""); + w.pub_fn("file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto", |w| { + w.unsafe_expr(|w| { + w.block("file_descriptor_proto_lazy.get(|| {", "})", |w| { + w.write_line("parse_descriptor_proto()"); + }); + }); + }); +} + +fn gen_file( + file: &FileDescriptorProto, + _files_map: &HashMap<&str, &FileDescriptorProto>, + root_scope: &RootScope, +) -> Option { + let scope = FileScope { file_descriptor: file }.to_scope(); + + if scope.get_messages().is_empty() && scope.get_enums().is_empty() && + file.get_extension().is_empty() + { + // protoc generates empty file descriptors for directories: skip them + return None; + } + + let mut v = Vec::new(); + + { + let mut w = CodeWriter::new(&mut v); + + w.write_generated(); + + w.write_line(""); + w.write_line("use protobuf::Message as Message_imported_for_functions;"); + w.write_line( + "use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions;", + ); + + for message in &scope.get_messages() { + // ignore map entries, because they are not used in map fields + if message.map_entry().is_none() { + w.write_line(""); + MessageGen::new(message, &root_scope).write(&mut w); + } + } + for enum_type in &scope.get_enums() { + w.write_line(""); + EnumGen::new(enum_type, file).write(&mut w); + } + + write_extensions(file, &root_scope, &mut w); + + if file.get_options().get_optimize_for() != FileOptions_OptimizeMode::LITE_RUNTIME { + w.write_line(""); + write_file_descriptor_data(file, &mut w); + } + } + + Some(compiler_plugin::GenResult { + name: format!("{}.rs", proto_path_to_rust_mod(file.get_name())), + content: v, + }) +} + +// This function is also used externally by cargo plugin +// https://github.com/plietar/rust-protobuf-build +// So be careful changing its signature. +pub fn gen( + file_descriptors: &[FileDescriptorProto], + files_to_generate: &[String], +) -> Vec { + let root_scope = RootScope { file_descriptors: file_descriptors }; + + let mut results: Vec = Vec::new(); + let files_map: HashMap<&str, &FileDescriptorProto> = + file_descriptors.iter().map(|f| (f.get_name(), f)).collect(); + + let all_file_names: Vec<&str> = file_descriptors.iter().map(|f| f.get_name()).collect(); + + for file_name in files_to_generate { + let file = files_map.get(&file_name[..]).expect(&format!( + "file not found in file descriptors: {:?}, files: {:?}", + file_name, + all_file_names + )); + results.extend(gen_file(file, &files_map, &root_scope)); + } + results +} + +pub fn protoc_gen_rust_main() { + compiler_plugin::plugin_main(gen); +} diff --git a/third_party/protobuf/src/codegen/rust_types_values.rs b/third_party/protobuf/src/codegen/rust_types_values.rs new file mode 100644 index 000000000..8c1ec6027 --- /dev/null +++ b/third_party/protobuf/src/codegen/rust_types_values.rs @@ -0,0 +1,505 @@ +use std::fmt; +use std::cmp; + +use descriptor::*; +use descriptorx::*; +use super::well_known_types::is_well_known_type_full; + + +// Represent subset of rust types used in generated code +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum RustType { + // integer: signed?, size in bits + Int(bool, u32), + // param is size in bits + Float(u32), + Bool, + Vec(Box), + HashMap(Box, Box), + String, + // [T], not &[T] + Slice(Box), + // str, not &str + Str, + Option(Box), + SingularField(Box), + SingularPtrField(Box), + RepeatedField(Box), + // Box + Uniq(Box), + // &T + Ref(Box), + // protobuf message + Message(String), + // protobuf enum, not any enum + Enum(String, String), + // oneof enum + Oneof(String), + // bytes::Bytes + Bytes, + // chars::Chars + Chars, + // group + Group, +} + +impl fmt::Display for RustType { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + RustType::Int(true, bits) => write!(f, "i{}", bits), + RustType::Int(false, bits) => write!(f, "u{}", bits), + RustType::Float(bits) => write!(f, "f{}", bits), + RustType::Bool => write!(f, "bool"), + RustType::Vec(ref param) => write!(f, "::std::vec::Vec<{}>", **param), + RustType::HashMap(ref key, ref value) => { + write!(f, "::std::collections::HashMap<{}, {}>", **key, **value) + } + RustType::String => write!(f, "::std::string::String"), + RustType::Slice(ref param) => write!(f, "[{}]", **param), + RustType::Str => write!(f, "str"), + RustType::Option(ref param) => write!(f, "::std::option::Option<{}>", **param), + RustType::SingularField(ref param) => { + write!(f, "::protobuf::SingularField<{}>", **param) + } + RustType::SingularPtrField(ref param) => { + write!(f, "::protobuf::SingularPtrField<{}>", **param) + } + RustType::RepeatedField(ref param) => { + write!(f, "::protobuf::RepeatedField<{}>", **param) + } + RustType::Uniq(ref param) => write!(f, "::std::boxed::Box<{}>", **param), + RustType::Ref(ref param) => write!(f, "&{}", **param), + RustType::Message(ref name) | + RustType::Enum(ref name, _) | + RustType::Oneof(ref name) => write!(f, "{}", name), + RustType::Group => write!(f, ""), + RustType::Bytes => write!(f, "::bytes::Bytes"), + RustType::Chars => write!(f, "::protobuf::chars::Chars"), + } + } +} + +impl RustType { + pub fn u8() -> RustType { + RustType::Int(false, 8) + } + + /// Type is rust primitive? + pub fn is_primitive(&self) -> bool { + match *self { + RustType::Int(..) | + RustType::Float(..) | + RustType::Bool => true, + _ => false, + } + } + + pub fn is_copy(&self) -> bool { + if self.is_primitive() { + true + } else if let RustType::Enum(..) = *self { + true + } else { + false + } + } + + fn is_str(&self) -> bool { + match *self { + RustType::Str => true, + _ => false, + } + } + + fn is_string(&self) -> bool { + match *self { + RustType::String => true, + _ => false, + } + } + + fn is_slice(&self) -> bool { + match *self { + RustType::Slice(..) => true, + _ => false, + } + } + + fn is_message(&self) -> bool { + match *self { + RustType::Message(..) => true, + _ => false, + } + } + + fn is_enum(&self) -> bool { + match *self { + RustType::Enum(..) => true, + _ => false, + } + } + + pub fn is_u8(&self) -> bool { + match *self { + RustType::Int(false, 8) => true, + _ => false, + } + } + + pub fn is_ref(&self) -> bool { + match *self { + RustType::Ref(..) => true, + _ => false, + } + } + + // default value for type + pub fn default_value(&self) -> String { + match *self { + RustType::Ref(ref t) if t.is_str() => "\"\"".to_string(), + RustType::Ref(ref t) if t.is_slice() => "&[]".to_string(), + RustType::Int(..) => "0".to_string(), + RustType::Float(..) => "0.".to_string(), + RustType::Bool => "false".to_string(), + RustType::Vec(..) => "::std::vec::Vec::new()".to_string(), + RustType::HashMap(..) => "::std::collections::HashMap::new()".to_string(), + RustType::String => "::std::string::String::new()".to_string(), + RustType::Bytes => "::bytes::Bytes::new()".to_string(), + RustType::Chars => "::protobuf::chars::Chars::new()".to_string(), + RustType::Option(..) => "::std::option::Option::None".to_string(), + RustType::SingularField(..) => "::protobuf::SingularField::none()".to_string(), + RustType::SingularPtrField(..) => "::protobuf::SingularPtrField::none()".to_string(), + RustType::RepeatedField(..) => "::protobuf::RepeatedField::new()".to_string(), + RustType::Message(ref name) => format!("{}::new()", name), + RustType::Ref(ref m) if m.is_message() => { + match **m { + RustType::Message(ref name) => format!("{}::default_instance()", name), + _ => unreachable!(), + } + } + // Note: default value of enum type may not be equal to default value of field + RustType::Enum(ref name, ref default) => format!("{}::{}", name, default), + _ => panic!("cannot create default value for: {}", *self), + } + } + + pub fn default_value_typed(self) -> RustValueTyped { + RustValueTyped { + value: self.default_value(), + rust_type: self, + } + } + + /// Emit a code to clear a variable `v` + pub fn clear(&self, v: &str) -> String { + match *self { + RustType::Option(..) => format!("{} = ::std::option::Option::None", v), + RustType::Vec(..) | + RustType::Bytes | + RustType::String | + RustType::RepeatedField(..) | + RustType::SingularField(..) | + RustType::SingularPtrField(..) | + RustType::HashMap(..) => format!("{}.clear()", v), + RustType::Chars => format!("::protobuf::Clear::clear(&mut {})", v), + RustType::Bool | + RustType::Float(..) | + RustType::Int(..) | + RustType::Enum(..) => format!("{} = {}", v, self.default_value()), + ref ty => panic!("cannot clear type: {:?}", ty), + } + } + + // wrap value in storage type + pub fn wrap_value(&self, value: &str) -> String { + match *self { + RustType::Option(..) => format!("::std::option::Option::Some({})", value), + RustType::SingularField(..) => format!("::protobuf::SingularField::some({})", value), + RustType::SingularPtrField(..) => { + format!("::protobuf::SingularPtrField::some({})", value) + } + _ => panic!("not a wrapper type: {}", *self), + } + } + + // expression to convert `v` of type `self` to type `target` + pub fn into_target(&self, target: &RustType, v: &str) -> String { + self.try_into_target(target, v) + .expect(&format!("failed to convert {} into {}", self, target)) + } + + fn try_into_target(&self, target: &RustType, v: &str) -> Result { + match (self, target) { + (x, y) if x == y => return Ok(format!("{}", v)), + (&RustType::Ref(ref x), y) if **x == *y => return Ok(format!("*{}", v)), + (x, &RustType::Uniq(ref y)) if *x == **y => { + return Ok(format!("::std::boxed::Box::new({})", v)) + } + (&RustType::Uniq(ref x), y) if **x == *y => return Ok(format!("*{}", v)), + (&RustType::String, &RustType::Ref(ref t)) if **t == RustType::Str => { + return Ok(format!("&{}", v)) + } + (&RustType::Chars, &RustType::Ref(ref t)) if **t == RustType::Str => { + return Ok(format!("&{}", v)) + } + (&RustType::Ref(ref t1), &RustType::Ref(ref t2)) if t1.is_string() && t2.is_str() => { + return Ok(format!("&{}", v)) + } + (&RustType::Ref(ref t1), &RustType::String) + if match **t1 { + RustType::Str => true, + _ => false, + } => return Ok(format!("{}.to_owned()", v)), + (&RustType::Ref(ref t1), &RustType::Vec(ref t2)) + if match (&**t1, &**t2) { + (&RustType::Slice(ref x), ref y) => **x == **y, + _ => false, + } => return Ok(format!("{}.to_vec()", v)), + (&RustType::Vec(ref x), &RustType::Ref(ref t)) + if match **t { + RustType::Slice(ref y) => x == y, + _ => false, + } => return Ok(format!("&{}", v)), + (&RustType::Bytes, &RustType::Ref(ref t)) + if match **t { + RustType::Slice(ref y) => **y == RustType::u8(), + _ => false, + } => return Ok(format!("&{}", v)), + (&RustType::Ref(ref t1), &RustType::Ref(ref t2)) + if match (&**t1, &**t2) { + (&RustType::Vec(ref x), &RustType::Slice(ref y)) => x == y, + _ => false, + } => return Ok(format!("&{}", v)), + (&RustType::Enum(..), &RustType::Int(true, 32)) => return Ok(format!("{}.value()", v)), + (&RustType::Ref(ref t), &RustType::Int(true, 32)) if t.is_enum() => { + return Ok(format!("{}.value()", v)) + } + _ => (), + }; + + if let &RustType::Ref(ref s) = self { + if let Ok(conv) = s.try_into_target(target, v) { + return Ok(conv); + } + } + + Err(()) + } + + /// Type to view data of this type + pub fn ref_type(&self) -> RustType { + RustType::Ref(Box::new(match self { + &RustType::String | + &RustType::Chars => RustType::Str, + &RustType::Vec(ref p) | + &RustType::RepeatedField(ref p) => RustType::Slice(p.clone()), + &RustType::Bytes => RustType::Slice(Box::new(RustType::u8())), + &RustType::Message(ref p) => RustType::Message(p.clone()), + x => panic!("no ref type for {}", x), + })) + } + + pub fn elem_type(&self) -> RustType { + match self { + &RustType::Option(ref ty) => (**ty).clone(), + x => panic!("cannot get elem type of {}", x), + } + } + + // type of `v` in `for v in xxx` + pub fn iter_elem_type(&self) -> RustType { + match self { + &RustType::Vec(ref ty) | + &RustType::Option(ref ty) | + &RustType::RepeatedField(ref ty) | + &RustType::SingularField(ref ty) | + &RustType::SingularPtrField(ref ty) => RustType::Ref(ty.clone()), + x => panic!("cannot iterate {}", x), + } + } + + pub fn value(self, value: String) -> RustValueTyped { + RustValueTyped { + value: value, + rust_type: self, + } + } +} + + +/// Representation of an expression in code generator: text and type +pub struct RustValueTyped { + pub value: String, + pub rust_type: RustType, +} + +impl RustValueTyped { + pub fn into_type(&self, target: RustType) -> RustValueTyped { + let target_value = self.rust_type.into_target(&target, &self.value); + RustValueTyped { + value: target_value, + rust_type: target, + } + } + + pub fn boxed(self) -> RustValueTyped { + self.into_type(RustType::Uniq(Box::new(self.rust_type.clone()))) + } +} + + +// protobuf type name for protobuf base type +pub fn protobuf_name(field_type: FieldDescriptorProto_Type) -> &'static str { + match field_type { + FieldDescriptorProto_Type::TYPE_DOUBLE => "double", + FieldDescriptorProto_Type::TYPE_FLOAT => "float", + FieldDescriptorProto_Type::TYPE_INT32 => "int32", + FieldDescriptorProto_Type::TYPE_INT64 => "int64", + FieldDescriptorProto_Type::TYPE_UINT32 => "uint32", + FieldDescriptorProto_Type::TYPE_UINT64 => "uint64", + FieldDescriptorProto_Type::TYPE_SINT32 => "sint32", + FieldDescriptorProto_Type::TYPE_SINT64 => "sint64", + FieldDescriptorProto_Type::TYPE_FIXED32 => "fixed32", + FieldDescriptorProto_Type::TYPE_FIXED64 => "fixed64", + FieldDescriptorProto_Type::TYPE_SFIXED32 => "sfixed32", + FieldDescriptorProto_Type::TYPE_SFIXED64 => "sfixed64", + FieldDescriptorProto_Type::TYPE_BOOL => "bool", + FieldDescriptorProto_Type::TYPE_STRING => "string", + FieldDescriptorProto_Type::TYPE_BYTES => "bytes", + FieldDescriptorProto_Type::TYPE_ENUM => "enum", + FieldDescriptorProto_Type::TYPE_MESSAGE => "message", + FieldDescriptorProto_Type::TYPE_GROUP => "group", + } +} + + +// rust type for protobuf base type +pub fn rust_name(field_type: FieldDescriptorProto_Type) -> RustType { + match field_type { + FieldDescriptorProto_Type::TYPE_DOUBLE => RustType::Float(64), + FieldDescriptorProto_Type::TYPE_FLOAT => RustType::Float(32), + FieldDescriptorProto_Type::TYPE_INT32 => RustType::Int(true, 32), + FieldDescriptorProto_Type::TYPE_INT64 => RustType::Int(true, 64), + FieldDescriptorProto_Type::TYPE_UINT32 => RustType::Int(false, 32), + FieldDescriptorProto_Type::TYPE_UINT64 => RustType::Int(false, 64), + FieldDescriptorProto_Type::TYPE_SINT32 => RustType::Int(true, 32), + FieldDescriptorProto_Type::TYPE_SINT64 => RustType::Int(true, 64), + FieldDescriptorProto_Type::TYPE_FIXED32 => RustType::Int(false, 32), + FieldDescriptorProto_Type::TYPE_FIXED64 => RustType::Int(false, 64), + FieldDescriptorProto_Type::TYPE_SFIXED32 => RustType::Int(true, 32), + FieldDescriptorProto_Type::TYPE_SFIXED64 => RustType::Int(true, 64), + FieldDescriptorProto_Type::TYPE_BOOL => RustType::Bool, + FieldDescriptorProto_Type::TYPE_STRING => RustType::String, + FieldDescriptorProto_Type::TYPE_BYTES => RustType::Vec(Box::new(RustType::Int(false, 8))), + FieldDescriptorProto_Type::TYPE_ENUM | + FieldDescriptorProto_Type::TYPE_GROUP | + FieldDescriptorProto_Type::TYPE_MESSAGE => { + panic!("there is no rust name for {:?}", field_type) + } + } +} + +fn file_last_component(file: &str) -> &str { + let bs = file.rfind('\\').map(|i| i + 1).unwrap_or(0); + let fs = file.rfind('/').map(|i| i + 1).unwrap_or(0); + &file[cmp::max(fs, bs)..] +} + +#[cfg(test)] +#[test] +fn test_file_last_component() { + assert_eq!("ab.proto", file_last_component("ab.proto")); + assert_eq!("ab.proto", file_last_component("xx/ab.proto")); + assert_eq!("ab.proto", file_last_component("xx\\ab.proto")); + assert_eq!("ab.proto", file_last_component("yy\\xx\\ab.proto")); +} + +fn is_descriptor_proto(file: &FileDescriptorProto) -> bool { + file.get_package() == "google.protobuf" + && file_last_component(file.get_name()) == "descriptor.proto" +} + +pub fn type_name_to_rust_relative( + type_name: &str, + file: &FileDescriptorProto, + subm: bool, + root_scope: &RootScope, +) -> String { + let message_or_enum = root_scope.find_message_or_enum(type_name); + if message_or_enum.get_scope().get_file_descriptor().get_name() == file.get_name() { + // field type is a message or enum declared in the same file + if subm { + format!("super::{}", message_or_enum.rust_name()) + } else { + format!("{}", message_or_enum.rust_name()) + } + } else if let Some(name) = is_well_known_type_full(type_name) { + // Well-known types are included in rust-protobuf library + // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf + format!("::protobuf::well_known_types::{}", name) + } else if is_descriptor_proto(message_or_enum.get_file_descriptor()) { + // Messages defined in descriptor.proto + format!("::protobuf::descriptor::{}", message_or_enum.name_to_package()) + } else { + if subm { + format!("super::super::{}", message_or_enum.rust_fq_name()) + } else { + format!("super::{}", message_or_enum.rust_fq_name()) + } + } +} + + +fn capitalize(s: &str) -> String { + if s.is_empty() { + return String::new(); + } + s[..1].to_uppercase() + &s[1..] +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum PrimitiveTypeVariant { + Default, + Carllerche, +} + +pub enum _CarllercheBytesType { + Bytes, + Chars, +} + +// ProtobufType trait name +pub enum ProtobufTypeGen { + Primitive(FieldDescriptorProto_Type, PrimitiveTypeVariant), + Message(String), + Enum(String), +} + +impl ProtobufTypeGen { + pub fn rust_type(&self) -> String { + match self { + &ProtobufTypeGen::Primitive(t, PrimitiveTypeVariant::Default) => { + format!( + "::protobuf::types::ProtobufType{}", + capitalize(protobuf_name(t)) + ) + } + &ProtobufTypeGen::Primitive( + FieldDescriptorProto_Type::TYPE_BYTES, + PrimitiveTypeVariant::Carllerche, + ) => format!("::protobuf::types::ProtobufTypeCarllercheBytes"), + &ProtobufTypeGen::Primitive( + FieldDescriptorProto_Type::TYPE_STRING, + PrimitiveTypeVariant::Carllerche, + ) => format!("::protobuf::types::ProtobufTypeCarllercheChars"), + &ProtobufTypeGen::Primitive(.., PrimitiveTypeVariant::Carllerche) => unreachable!(), + &ProtobufTypeGen::Message(ref name) => { + format!("::protobuf::types::ProtobufTypeMessage<{}>", name) + } + &ProtobufTypeGen::Enum(ref name) => { + format!("::protobuf::types::ProtobufTypeEnum<{}>", name) + } + } + } +} diff --git a/third_party/protobuf/src/codegen/well_known_types.rs b/third_party/protobuf/src/codegen/well_known_types.rs new file mode 100644 index 000000000..626494788 --- /dev/null +++ b/third_party/protobuf/src/codegen/well_known_types.rs @@ -0,0 +1,63 @@ +static NAMES: &'static [&'static str] = &[ + "Any", + "Api", + "BoolValue", + "BytesValue", + "DoubleValue", + "Duration", + "Empty", + "Enum", + "EnumValue", + "Field", + // TODO: dotted names + "Field.Cardinality", + "Field.Kind", + "FieldMask", + "FloatValue", + "Int32Value", + "Int64Value", + "ListValue", + "Method", + "Mixin", + "NullValue", + "Option", + "SourceContext", + "StringValue", + "Struct", + "Syntax", + "Timestamp", + "Type", + "UInt32Value", + "UInt64Value", + "Value", +]; + +fn is_well_known_type(name: &str) -> bool { + NAMES.iter().any(|&n| n == name) +} + +pub fn is_well_known_type_full(name: &str) -> Option<&str> { + if let Some(dot) = name.rfind('.') { + if &name[..dot] == ".google.protobuf" && is_well_known_type(&name[dot + 1..]) { + Some(&name[dot + 1..]) + } else { + None + } + } else { + None + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_is_well_known_type_full() { + assert_eq!( + Some("BoolValue"), + is_well_known_type_full(".google.protobuf.BoolValue") + ); + assert_eq!(None, is_well_known_type_full(".google.protobuf.Fgfg")); + } +} diff --git a/third_party/protobuf/src/compiler_plugin.rs b/third_party/protobuf/src/compiler_plugin.rs new file mode 100644 index 000000000..ab2fa017b --- /dev/null +++ b/third_party/protobuf/src/compiler_plugin.rs @@ -0,0 +1,37 @@ +use std::io::stdin; +use std::io::stdout; +use std::str; +use std::string::String; +use std::string::ToString; +use std::vec::Vec; +use plugin::*; +use protobuf::parse_from_reader; +use protobuf::Message; +use protobuf::descriptor::FileDescriptorProto; + + +pub struct GenResult { + pub name: String, + pub content: Vec, +} + +pub fn plugin_main( + gen: fn(file_descriptors: &[FileDescriptorProto], files_to_generate: &[String]) + -> Vec, +) { + let req = parse_from_reader::(&mut stdin()).unwrap(); + let result = gen(req.get_proto_file(), req.get_file_to_generate()); + let mut resp = CodeGeneratorResponse::new(); + resp.set_file( + result + .iter() + .map(|file| { + let mut r = CodeGeneratorResponse_File::new(); + r.set_name(file.name.to_string()); + r.set_content(str::from_utf8(file.content.as_ref()).unwrap().to_string()); + r + }) + .collect(), + ); + resp.write_to_writer(&mut stdout()).unwrap(); +} diff --git a/third_party/protobuf/src/descriptor.rs b/third_party/protobuf/src/descriptor.rs new file mode 100644 index 000000000..ae6aa9817 --- /dev/null +++ b/third_party/protobuf/src/descriptor.rs @@ -0,0 +1,10826 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +use std::string::ToString; +use std::boxed::Box; + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +#[derive(PartialEq,Clone,Default)] +pub struct FileDescriptorSet { + // message fields + file: ::protobuf::RepeatedField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for FileDescriptorSet {} + +impl FileDescriptorSet { + pub fn new() -> FileDescriptorSet { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static FileDescriptorSet { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const FileDescriptorSet, + }; + unsafe { + instance.get(FileDescriptorSet::new) + } + } + + // repeated .google.protobuf.FileDescriptorProto file = 1; + + pub fn clear_file(&mut self) { + self.file.clear(); + } + + // Param is passed by value, moved + pub fn set_file(&mut self, v: ::protobuf::RepeatedField) { + self.file = v; + } + + // Mutable pointer to the field. + pub fn mut_file(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.file + } + + // Take field + pub fn take_file(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.file, ::protobuf::RepeatedField::new()) + } + + pub fn get_file(&self) -> &[FileDescriptorProto] { + &self.file + } + + fn get_file_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.file + } + + fn mut_file_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.file + } +} + +impl ::protobuf::Message for FileDescriptorSet { + fn is_initialized(&self) -> bool { + for v in &self.file { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.file)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + for value in &self.file { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + for v in &self.file { + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for FileDescriptorSet { + fn new() -> FileDescriptorSet { + FileDescriptorSet::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "file", + FileDescriptorSet::get_file_for_reflect, + FileDescriptorSet::mut_file_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "FileDescriptorSet", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for FileDescriptorSet { + fn clear(&mut self) { + self.clear_file(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for FileDescriptorSet { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for FileDescriptorSet { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct FileDescriptorProto { + // message fields + name: ::protobuf::SingularField<::std::string::String>, + package: ::protobuf::SingularField<::std::string::String>, + dependency: ::protobuf::RepeatedField<::std::string::String>, + public_dependency: ::std::vec::Vec, + weak_dependency: ::std::vec::Vec, + message_type: ::protobuf::RepeatedField, + enum_type: ::protobuf::RepeatedField, + service: ::protobuf::RepeatedField, + extension: ::protobuf::RepeatedField, + options: ::protobuf::SingularPtrField, + source_code_info: ::protobuf::SingularPtrField, + syntax: ::protobuf::SingularField<::std::string::String>, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for FileDescriptorProto {} + +impl FileDescriptorProto { + pub fn new() -> FileDescriptorProto { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static FileDescriptorProto { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const FileDescriptorProto, + }; + unsafe { + instance.get(FileDescriptorProto::new) + } + } + + // optional string name = 1; + + pub fn clear_name(&mut self) { + self.name.clear(); + } + + pub fn has_name(&self) -> bool { + self.name.is_some() + } + + // Param is passed by value, moved + pub fn set_name(&mut self, v: ::std::string::String) { + self.name = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_name(&mut self) -> &mut ::std::string::String { + if self.name.is_none() { + self.name.set_default(); + } + self.name.as_mut().unwrap() + } + + // Take field + pub fn take_name(&mut self) -> ::std::string::String { + self.name.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_name(&self) -> &str { + match self.name.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_name_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.name + } + + fn mut_name_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.name + } + + // optional string package = 2; + + pub fn clear_package(&mut self) { + self.package.clear(); + } + + pub fn has_package(&self) -> bool { + self.package.is_some() + } + + // Param is passed by value, moved + pub fn set_package(&mut self, v: ::std::string::String) { + self.package = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_package(&mut self) -> &mut ::std::string::String { + if self.package.is_none() { + self.package.set_default(); + } + self.package.as_mut().unwrap() + } + + // Take field + pub fn take_package(&mut self) -> ::std::string::String { + self.package.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_package(&self) -> &str { + match self.package.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_package_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.package + } + + fn mut_package_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.package + } + + // repeated string dependency = 3; + + pub fn clear_dependency(&mut self) { + self.dependency.clear(); + } + + // Param is passed by value, moved + pub fn set_dependency(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { + self.dependency = v; + } + + // Mutable pointer to the field. + pub fn mut_dependency(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.dependency + } + + // Take field + pub fn take_dependency(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { + ::std::mem::replace(&mut self.dependency, ::protobuf::RepeatedField::new()) + } + + pub fn get_dependency(&self) -> &[::std::string::String] { + &self.dependency + } + + fn get_dependency_for_reflect(&self) -> &::protobuf::RepeatedField<::std::string::String> { + &self.dependency + } + + fn mut_dependency_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.dependency + } + + // repeated int32 public_dependency = 10; + + pub fn clear_public_dependency(&mut self) { + self.public_dependency.clear(); + } + + // Param is passed by value, moved + pub fn set_public_dependency(&mut self, v: ::std::vec::Vec) { + self.public_dependency = v; + } + + // Mutable pointer to the field. + pub fn mut_public_dependency(&mut self) -> &mut ::std::vec::Vec { + &mut self.public_dependency + } + + // Take field + pub fn take_public_dependency(&mut self) -> ::std::vec::Vec { + ::std::mem::replace(&mut self.public_dependency, ::std::vec::Vec::new()) + } + + pub fn get_public_dependency(&self) -> &[i32] { + &self.public_dependency + } + + fn get_public_dependency_for_reflect(&self) -> &::std::vec::Vec { + &self.public_dependency + } + + fn mut_public_dependency_for_reflect(&mut self) -> &mut ::std::vec::Vec { + &mut self.public_dependency + } + + // repeated int32 weak_dependency = 11; + + pub fn clear_weak_dependency(&mut self) { + self.weak_dependency.clear(); + } + + // Param is passed by value, moved + pub fn set_weak_dependency(&mut self, v: ::std::vec::Vec) { + self.weak_dependency = v; + } + + // Mutable pointer to the field. + pub fn mut_weak_dependency(&mut self) -> &mut ::std::vec::Vec { + &mut self.weak_dependency + } + + // Take field + pub fn take_weak_dependency(&mut self) -> ::std::vec::Vec { + ::std::mem::replace(&mut self.weak_dependency, ::std::vec::Vec::new()) + } + + pub fn get_weak_dependency(&self) -> &[i32] { + &self.weak_dependency + } + + fn get_weak_dependency_for_reflect(&self) -> &::std::vec::Vec { + &self.weak_dependency + } + + fn mut_weak_dependency_for_reflect(&mut self) -> &mut ::std::vec::Vec { + &mut self.weak_dependency + } + + // repeated .google.protobuf.DescriptorProto message_type = 4; + + pub fn clear_message_type(&mut self) { + self.message_type.clear(); + } + + // Param is passed by value, moved + pub fn set_message_type(&mut self, v: ::protobuf::RepeatedField) { + self.message_type = v; + } + + // Mutable pointer to the field. + pub fn mut_message_type(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.message_type + } + + // Take field + pub fn take_message_type(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.message_type, ::protobuf::RepeatedField::new()) + } + + pub fn get_message_type(&self) -> &[DescriptorProto] { + &self.message_type + } + + fn get_message_type_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.message_type + } + + fn mut_message_type_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.message_type + } + + // repeated .google.protobuf.EnumDescriptorProto enum_type = 5; + + pub fn clear_enum_type(&mut self) { + self.enum_type.clear(); + } + + // Param is passed by value, moved + pub fn set_enum_type(&mut self, v: ::protobuf::RepeatedField) { + self.enum_type = v; + } + + // Mutable pointer to the field. + pub fn mut_enum_type(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.enum_type + } + + // Take field + pub fn take_enum_type(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.enum_type, ::protobuf::RepeatedField::new()) + } + + pub fn get_enum_type(&self) -> &[EnumDescriptorProto] { + &self.enum_type + } + + fn get_enum_type_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.enum_type + } + + fn mut_enum_type_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.enum_type + } + + // repeated .google.protobuf.ServiceDescriptorProto service = 6; + + pub fn clear_service(&mut self) { + self.service.clear(); + } + + // Param is passed by value, moved + pub fn set_service(&mut self, v: ::protobuf::RepeatedField) { + self.service = v; + } + + // Mutable pointer to the field. + pub fn mut_service(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.service + } + + // Take field + pub fn take_service(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.service, ::protobuf::RepeatedField::new()) + } + + pub fn get_service(&self) -> &[ServiceDescriptorProto] { + &self.service + } + + fn get_service_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.service + } + + fn mut_service_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.service + } + + // repeated .google.protobuf.FieldDescriptorProto extension = 7; + + pub fn clear_extension(&mut self) { + self.extension.clear(); + } + + // Param is passed by value, moved + pub fn set_extension(&mut self, v: ::protobuf::RepeatedField) { + self.extension = v; + } + + // Mutable pointer to the field. + pub fn mut_extension(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.extension + } + + // Take field + pub fn take_extension(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.extension, ::protobuf::RepeatedField::new()) + } + + pub fn get_extension(&self) -> &[FieldDescriptorProto] { + &self.extension + } + + fn get_extension_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.extension + } + + fn mut_extension_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.extension + } + + // optional .google.protobuf.FileOptions options = 8; + + pub fn clear_options(&mut self) { + self.options.clear(); + } + + pub fn has_options(&self) -> bool { + self.options.is_some() + } + + // Param is passed by value, moved + pub fn set_options(&mut self, v: FileOptions) { + self.options = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_options(&mut self) -> &mut FileOptions { + if self.options.is_none() { + self.options.set_default(); + } + self.options.as_mut().unwrap() + } + + // Take field + pub fn take_options(&mut self) -> FileOptions { + self.options.take().unwrap_or_else(|| FileOptions::new()) + } + + pub fn get_options(&self) -> &FileOptions { + self.options.as_ref().unwrap_or_else(|| FileOptions::default_instance()) + } + + fn get_options_for_reflect(&self) -> &::protobuf::SingularPtrField { + &self.options + } + + fn mut_options_for_reflect(&mut self) -> &mut ::protobuf::SingularPtrField { + &mut self.options + } + + // optional .google.protobuf.SourceCodeInfo source_code_info = 9; + + pub fn clear_source_code_info(&mut self) { + self.source_code_info.clear(); + } + + pub fn has_source_code_info(&self) -> bool { + self.source_code_info.is_some() + } + + // Param is passed by value, moved + pub fn set_source_code_info(&mut self, v: SourceCodeInfo) { + self.source_code_info = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_source_code_info(&mut self) -> &mut SourceCodeInfo { + if self.source_code_info.is_none() { + self.source_code_info.set_default(); + } + self.source_code_info.as_mut().unwrap() + } + + // Take field + pub fn take_source_code_info(&mut self) -> SourceCodeInfo { + self.source_code_info.take().unwrap_or_else(|| SourceCodeInfo::new()) + } + + pub fn get_source_code_info(&self) -> &SourceCodeInfo { + self.source_code_info.as_ref().unwrap_or_else(|| SourceCodeInfo::default_instance()) + } + + fn get_source_code_info_for_reflect(&self) -> &::protobuf::SingularPtrField { + &self.source_code_info + } + + fn mut_source_code_info_for_reflect(&mut self) -> &mut ::protobuf::SingularPtrField { + &mut self.source_code_info + } + + // optional string syntax = 12; + + pub fn clear_syntax(&mut self) { + self.syntax.clear(); + } + + pub fn has_syntax(&self) -> bool { + self.syntax.is_some() + } + + // Param is passed by value, moved + pub fn set_syntax(&mut self, v: ::std::string::String) { + self.syntax = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_syntax(&mut self) -> &mut ::std::string::String { + if self.syntax.is_none() { + self.syntax.set_default(); + } + self.syntax.as_mut().unwrap() + } + + // Take field + pub fn take_syntax(&mut self) -> ::std::string::String { + self.syntax.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_syntax(&self) -> &str { + match self.syntax.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_syntax_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.syntax + } + + fn mut_syntax_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.syntax + } +} + +impl ::protobuf::Message for FileDescriptorProto { + fn is_initialized(&self) -> bool { + for v in &self.message_type { + if !v.is_initialized() { + return false; + } + }; + for v in &self.enum_type { + if !v.is_initialized() { + return false; + } + }; + for v in &self.service { + if !v.is_initialized() { + return false; + } + }; + for v in &self.extension { + if !v.is_initialized() { + return false; + } + }; + for v in &self.options { + if !v.is_initialized() { + return false; + } + }; + for v in &self.source_code_info { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.name)?; + }, + 2 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.package)?; + }, + 3 => { + ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.dependency)?; + }, + 10 => { + ::protobuf::rt::read_repeated_int32_into(wire_type, is, &mut self.public_dependency)?; + }, + 11 => { + ::protobuf::rt::read_repeated_int32_into(wire_type, is, &mut self.weak_dependency)?; + }, + 4 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.message_type)?; + }, + 5 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.enum_type)?; + }, + 6 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.service)?; + }, + 7 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.extension)?; + }, + 8 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.options)?; + }, + 9 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.source_code_info)?; + }, + 12 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.syntax)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.name.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(ref v) = self.package.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + for value in &self.dependency { + my_size += ::protobuf::rt::string_size(3, &value); + }; + for value in &self.public_dependency { + my_size += ::protobuf::rt::value_size(10, *value, ::protobuf::wire_format::WireTypeVarint); + }; + for value in &self.weak_dependency { + my_size += ::protobuf::rt::value_size(11, *value, ::protobuf::wire_format::WireTypeVarint); + }; + for value in &self.message_type { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + for value in &self.enum_type { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + for value in &self.service { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + for value in &self.extension { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + if let Some(ref v) = self.options.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + if let Some(ref v) = self.source_code_info.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + if let Some(ref v) = self.syntax.as_ref() { + my_size += ::protobuf::rt::string_size(12, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.name.as_ref() { + os.write_string(1, &v)?; + } + if let Some(ref v) = self.package.as_ref() { + os.write_string(2, &v)?; + } + for v in &self.dependency { + os.write_string(3, &v)?; + }; + for v in &self.public_dependency { + os.write_int32(10, *v)?; + }; + for v in &self.weak_dependency { + os.write_int32(11, *v)?; + }; + for v in &self.message_type { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + for v in &self.enum_type { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + for v in &self.service { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + for v in &self.extension { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + if let Some(ref v) = self.options.as_ref() { + os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + if let Some(ref v) = self.source_code_info.as_ref() { + os.write_tag(9, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + if let Some(ref v) = self.syntax.as_ref() { + os.write_string(12, &v)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for FileDescriptorProto { + fn new() -> FileDescriptorProto { + FileDescriptorProto::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "name", + FileDescriptorProto::get_name_for_reflect, + FileDescriptorProto::mut_name_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "package", + FileDescriptorProto::get_package_for_reflect, + FileDescriptorProto::mut_package_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "dependency", + FileDescriptorProto::get_dependency_for_reflect, + FileDescriptorProto::mut_dependency_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_vec_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "public_dependency", + FileDescriptorProto::get_public_dependency_for_reflect, + FileDescriptorProto::mut_public_dependency_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_vec_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "weak_dependency", + FileDescriptorProto::get_weak_dependency_for_reflect, + FileDescriptorProto::mut_weak_dependency_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "message_type", + FileDescriptorProto::get_message_type_for_reflect, + FileDescriptorProto::mut_message_type_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "enum_type", + FileDescriptorProto::get_enum_type_for_reflect, + FileDescriptorProto::mut_enum_type_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "service", + FileDescriptorProto::get_service_for_reflect, + FileDescriptorProto::mut_service_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "extension", + FileDescriptorProto::get_extension_for_reflect, + FileDescriptorProto::mut_extension_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "options", + FileDescriptorProto::get_options_for_reflect, + FileDescriptorProto::mut_options_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "source_code_info", + FileDescriptorProto::get_source_code_info_for_reflect, + FileDescriptorProto::mut_source_code_info_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "syntax", + FileDescriptorProto::get_syntax_for_reflect, + FileDescriptorProto::mut_syntax_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "FileDescriptorProto", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for FileDescriptorProto { + fn clear(&mut self) { + self.clear_name(); + self.clear_package(); + self.clear_dependency(); + self.clear_public_dependency(); + self.clear_weak_dependency(); + self.clear_message_type(); + self.clear_enum_type(); + self.clear_service(); + self.clear_extension(); + self.clear_options(); + self.clear_source_code_info(); + self.clear_syntax(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for FileDescriptorProto { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for FileDescriptorProto { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct DescriptorProto { + // message fields + name: ::protobuf::SingularField<::std::string::String>, + field: ::protobuf::RepeatedField, + extension: ::protobuf::RepeatedField, + nested_type: ::protobuf::RepeatedField, + enum_type: ::protobuf::RepeatedField, + extension_range: ::protobuf::RepeatedField, + oneof_decl: ::protobuf::RepeatedField, + options: ::protobuf::SingularPtrField, + reserved_range: ::protobuf::RepeatedField, + reserved_name: ::protobuf::RepeatedField<::std::string::String>, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for DescriptorProto {} + +impl DescriptorProto { + pub fn new() -> DescriptorProto { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static DescriptorProto { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const DescriptorProto, + }; + unsafe { + instance.get(DescriptorProto::new) + } + } + + // optional string name = 1; + + pub fn clear_name(&mut self) { + self.name.clear(); + } + + pub fn has_name(&self) -> bool { + self.name.is_some() + } + + // Param is passed by value, moved + pub fn set_name(&mut self, v: ::std::string::String) { + self.name = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_name(&mut self) -> &mut ::std::string::String { + if self.name.is_none() { + self.name.set_default(); + } + self.name.as_mut().unwrap() + } + + // Take field + pub fn take_name(&mut self) -> ::std::string::String { + self.name.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_name(&self) -> &str { + match self.name.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_name_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.name + } + + fn mut_name_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.name + } + + // repeated .google.protobuf.FieldDescriptorProto field = 2; + + pub fn clear_field(&mut self) { + self.field.clear(); + } + + // Param is passed by value, moved + pub fn set_field(&mut self, v: ::protobuf::RepeatedField) { + self.field = v; + } + + // Mutable pointer to the field. + pub fn mut_field(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.field + } + + // Take field + pub fn take_field(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.field, ::protobuf::RepeatedField::new()) + } + + pub fn get_field(&self) -> &[FieldDescriptorProto] { + &self.field + } + + fn get_field_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.field + } + + fn mut_field_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.field + } + + // repeated .google.protobuf.FieldDescriptorProto extension = 6; + + pub fn clear_extension(&mut self) { + self.extension.clear(); + } + + // Param is passed by value, moved + pub fn set_extension(&mut self, v: ::protobuf::RepeatedField) { + self.extension = v; + } + + // Mutable pointer to the field. + pub fn mut_extension(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.extension + } + + // Take field + pub fn take_extension(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.extension, ::protobuf::RepeatedField::new()) + } + + pub fn get_extension(&self) -> &[FieldDescriptorProto] { + &self.extension + } + + fn get_extension_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.extension + } + + fn mut_extension_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.extension + } + + // repeated .google.protobuf.DescriptorProto nested_type = 3; + + pub fn clear_nested_type(&mut self) { + self.nested_type.clear(); + } + + // Param is passed by value, moved + pub fn set_nested_type(&mut self, v: ::protobuf::RepeatedField) { + self.nested_type = v; + } + + // Mutable pointer to the field. + pub fn mut_nested_type(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.nested_type + } + + // Take field + pub fn take_nested_type(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.nested_type, ::protobuf::RepeatedField::new()) + } + + pub fn get_nested_type(&self) -> &[DescriptorProto] { + &self.nested_type + } + + fn get_nested_type_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.nested_type + } + + fn mut_nested_type_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.nested_type + } + + // repeated .google.protobuf.EnumDescriptorProto enum_type = 4; + + pub fn clear_enum_type(&mut self) { + self.enum_type.clear(); + } + + // Param is passed by value, moved + pub fn set_enum_type(&mut self, v: ::protobuf::RepeatedField) { + self.enum_type = v; + } + + // Mutable pointer to the field. + pub fn mut_enum_type(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.enum_type + } + + // Take field + pub fn take_enum_type(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.enum_type, ::protobuf::RepeatedField::new()) + } + + pub fn get_enum_type(&self) -> &[EnumDescriptorProto] { + &self.enum_type + } + + fn get_enum_type_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.enum_type + } + + fn mut_enum_type_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.enum_type + } + + // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5; + + pub fn clear_extension_range(&mut self) { + self.extension_range.clear(); + } + + // Param is passed by value, moved + pub fn set_extension_range(&mut self, v: ::protobuf::RepeatedField) { + self.extension_range = v; + } + + // Mutable pointer to the field. + pub fn mut_extension_range(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.extension_range + } + + // Take field + pub fn take_extension_range(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.extension_range, ::protobuf::RepeatedField::new()) + } + + pub fn get_extension_range(&self) -> &[DescriptorProto_ExtensionRange] { + &self.extension_range + } + + fn get_extension_range_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.extension_range + } + + fn mut_extension_range_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.extension_range + } + + // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8; + + pub fn clear_oneof_decl(&mut self) { + self.oneof_decl.clear(); + } + + // Param is passed by value, moved + pub fn set_oneof_decl(&mut self, v: ::protobuf::RepeatedField) { + self.oneof_decl = v; + } + + // Mutable pointer to the field. + pub fn mut_oneof_decl(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.oneof_decl + } + + // Take field + pub fn take_oneof_decl(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.oneof_decl, ::protobuf::RepeatedField::new()) + } + + pub fn get_oneof_decl(&self) -> &[OneofDescriptorProto] { + &self.oneof_decl + } + + fn get_oneof_decl_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.oneof_decl + } + + fn mut_oneof_decl_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.oneof_decl + } + + // optional .google.protobuf.MessageOptions options = 7; + + pub fn clear_options(&mut self) { + self.options.clear(); + } + + pub fn has_options(&self) -> bool { + self.options.is_some() + } + + // Param is passed by value, moved + pub fn set_options(&mut self, v: MessageOptions) { + self.options = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_options(&mut self) -> &mut MessageOptions { + if self.options.is_none() { + self.options.set_default(); + } + self.options.as_mut().unwrap() + } + + // Take field + pub fn take_options(&mut self) -> MessageOptions { + self.options.take().unwrap_or_else(|| MessageOptions::new()) + } + + pub fn get_options(&self) -> &MessageOptions { + self.options.as_ref().unwrap_or_else(|| MessageOptions::default_instance()) + } + + fn get_options_for_reflect(&self) -> &::protobuf::SingularPtrField { + &self.options + } + + fn mut_options_for_reflect(&mut self) -> &mut ::protobuf::SingularPtrField { + &mut self.options + } + + // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9; + + pub fn clear_reserved_range(&mut self) { + self.reserved_range.clear(); + } + + // Param is passed by value, moved + pub fn set_reserved_range(&mut self, v: ::protobuf::RepeatedField) { + self.reserved_range = v; + } + + // Mutable pointer to the field. + pub fn mut_reserved_range(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.reserved_range + } + + // Take field + pub fn take_reserved_range(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.reserved_range, ::protobuf::RepeatedField::new()) + } + + pub fn get_reserved_range(&self) -> &[DescriptorProto_ReservedRange] { + &self.reserved_range + } + + fn get_reserved_range_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.reserved_range + } + + fn mut_reserved_range_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.reserved_range + } + + // repeated string reserved_name = 10; + + pub fn clear_reserved_name(&mut self) { + self.reserved_name.clear(); + } + + // Param is passed by value, moved + pub fn set_reserved_name(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { + self.reserved_name = v; + } + + // Mutable pointer to the field. + pub fn mut_reserved_name(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.reserved_name + } + + // Take field + pub fn take_reserved_name(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { + ::std::mem::replace(&mut self.reserved_name, ::protobuf::RepeatedField::new()) + } + + pub fn get_reserved_name(&self) -> &[::std::string::String] { + &self.reserved_name + } + + fn get_reserved_name_for_reflect(&self) -> &::protobuf::RepeatedField<::std::string::String> { + &self.reserved_name + } + + fn mut_reserved_name_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.reserved_name + } +} + +impl ::protobuf::Message for DescriptorProto { + fn is_initialized(&self) -> bool { + for v in &self.field { + if !v.is_initialized() { + return false; + } + }; + for v in &self.extension { + if !v.is_initialized() { + return false; + } + }; + for v in &self.nested_type { + if !v.is_initialized() { + return false; + } + }; + for v in &self.enum_type { + if !v.is_initialized() { + return false; + } + }; + for v in &self.extension_range { + if !v.is_initialized() { + return false; + } + }; + for v in &self.oneof_decl { + if !v.is_initialized() { + return false; + } + }; + for v in &self.options { + if !v.is_initialized() { + return false; + } + }; + for v in &self.reserved_range { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.name)?; + }, + 2 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.field)?; + }, + 6 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.extension)?; + }, + 3 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.nested_type)?; + }, + 4 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.enum_type)?; + }, + 5 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.extension_range)?; + }, + 8 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.oneof_decl)?; + }, + 7 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.options)?; + }, + 9 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.reserved_range)?; + }, + 10 => { + ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.reserved_name)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.name.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + for value in &self.field { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + for value in &self.extension { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + for value in &self.nested_type { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + for value in &self.enum_type { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + for value in &self.extension_range { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + for value in &self.oneof_decl { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + if let Some(ref v) = self.options.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + for value in &self.reserved_range { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + for value in &self.reserved_name { + my_size += ::protobuf::rt::string_size(10, &value); + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.name.as_ref() { + os.write_string(1, &v)?; + } + for v in &self.field { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + for v in &self.extension { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + for v in &self.nested_type { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + for v in &self.enum_type { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + for v in &self.extension_range { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + for v in &self.oneof_decl { + os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + if let Some(ref v) = self.options.as_ref() { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + for v in &self.reserved_range { + os.write_tag(9, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + for v in &self.reserved_name { + os.write_string(10, &v)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for DescriptorProto { + fn new() -> DescriptorProto { + DescriptorProto::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "name", + DescriptorProto::get_name_for_reflect, + DescriptorProto::mut_name_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "field", + DescriptorProto::get_field_for_reflect, + DescriptorProto::mut_field_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "extension", + DescriptorProto::get_extension_for_reflect, + DescriptorProto::mut_extension_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "nested_type", + DescriptorProto::get_nested_type_for_reflect, + DescriptorProto::mut_nested_type_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "enum_type", + DescriptorProto::get_enum_type_for_reflect, + DescriptorProto::mut_enum_type_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "extension_range", + DescriptorProto::get_extension_range_for_reflect, + DescriptorProto::mut_extension_range_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "oneof_decl", + DescriptorProto::get_oneof_decl_for_reflect, + DescriptorProto::mut_oneof_decl_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "options", + DescriptorProto::get_options_for_reflect, + DescriptorProto::mut_options_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "reserved_range", + DescriptorProto::get_reserved_range_for_reflect, + DescriptorProto::mut_reserved_range_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "reserved_name", + DescriptorProto::get_reserved_name_for_reflect, + DescriptorProto::mut_reserved_name_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "DescriptorProto", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for DescriptorProto { + fn clear(&mut self) { + self.clear_name(); + self.clear_field(); + self.clear_extension(); + self.clear_nested_type(); + self.clear_enum_type(); + self.clear_extension_range(); + self.clear_oneof_decl(); + self.clear_options(); + self.clear_reserved_range(); + self.clear_reserved_name(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for DescriptorProto { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for DescriptorProto { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct DescriptorProto_ExtensionRange { + // message fields + start: ::std::option::Option, + end: ::std::option::Option, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for DescriptorProto_ExtensionRange {} + +impl DescriptorProto_ExtensionRange { + pub fn new() -> DescriptorProto_ExtensionRange { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static DescriptorProto_ExtensionRange { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const DescriptorProto_ExtensionRange, + }; + unsafe { + instance.get(DescriptorProto_ExtensionRange::new) + } + } + + // optional int32 start = 1; + + pub fn clear_start(&mut self) { + self.start = ::std::option::Option::None; + } + + pub fn has_start(&self) -> bool { + self.start.is_some() + } + + // Param is passed by value, moved + pub fn set_start(&mut self, v: i32) { + self.start = ::std::option::Option::Some(v); + } + + pub fn get_start(&self) -> i32 { + self.start.unwrap_or(0) + } + + fn get_start_for_reflect(&self) -> &::std::option::Option { + &self.start + } + + fn mut_start_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.start + } + + // optional int32 end = 2; + + pub fn clear_end(&mut self) { + self.end = ::std::option::Option::None; + } + + pub fn has_end(&self) -> bool { + self.end.is_some() + } + + // Param is passed by value, moved + pub fn set_end(&mut self, v: i32) { + self.end = ::std::option::Option::Some(v); + } + + pub fn get_end(&self) -> i32 { + self.end.unwrap_or(0) + } + + fn get_end_for_reflect(&self) -> &::std::option::Option { + &self.end + } + + fn mut_end_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.end + } +} + +impl ::protobuf::Message for DescriptorProto_ExtensionRange { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int32()?; + self.start = ::std::option::Option::Some(tmp); + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int32()?; + self.end = ::std::option::Option::Some(tmp); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(v) = self.start { + my_size += ::protobuf::rt::value_size(1, v, ::protobuf::wire_format::WireTypeVarint); + } + if let Some(v) = self.end { + my_size += ::protobuf::rt::value_size(2, v, ::protobuf::wire_format::WireTypeVarint); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(v) = self.start { + os.write_int32(1, v)?; + } + if let Some(v) = self.end { + os.write_int32(2, v)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for DescriptorProto_ExtensionRange { + fn new() -> DescriptorProto_ExtensionRange { + DescriptorProto_ExtensionRange::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "start", + DescriptorProto_ExtensionRange::get_start_for_reflect, + DescriptorProto_ExtensionRange::mut_start_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "end", + DescriptorProto_ExtensionRange::get_end_for_reflect, + DescriptorProto_ExtensionRange::mut_end_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "DescriptorProto_ExtensionRange", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for DescriptorProto_ExtensionRange { + fn clear(&mut self) { + self.clear_start(); + self.clear_end(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for DescriptorProto_ExtensionRange { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for DescriptorProto_ExtensionRange { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct DescriptorProto_ReservedRange { + // message fields + start: ::std::option::Option, + end: ::std::option::Option, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for DescriptorProto_ReservedRange {} + +impl DescriptorProto_ReservedRange { + pub fn new() -> DescriptorProto_ReservedRange { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static DescriptorProto_ReservedRange { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const DescriptorProto_ReservedRange, + }; + unsafe { + instance.get(DescriptorProto_ReservedRange::new) + } + } + + // optional int32 start = 1; + + pub fn clear_start(&mut self) { + self.start = ::std::option::Option::None; + } + + pub fn has_start(&self) -> bool { + self.start.is_some() + } + + // Param is passed by value, moved + pub fn set_start(&mut self, v: i32) { + self.start = ::std::option::Option::Some(v); + } + + pub fn get_start(&self) -> i32 { + self.start.unwrap_or(0) + } + + fn get_start_for_reflect(&self) -> &::std::option::Option { + &self.start + } + + fn mut_start_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.start + } + + // optional int32 end = 2; + + pub fn clear_end(&mut self) { + self.end = ::std::option::Option::None; + } + + pub fn has_end(&self) -> bool { + self.end.is_some() + } + + // Param is passed by value, moved + pub fn set_end(&mut self, v: i32) { + self.end = ::std::option::Option::Some(v); + } + + pub fn get_end(&self) -> i32 { + self.end.unwrap_or(0) + } + + fn get_end_for_reflect(&self) -> &::std::option::Option { + &self.end + } + + fn mut_end_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.end + } +} + +impl ::protobuf::Message for DescriptorProto_ReservedRange { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int32()?; + self.start = ::std::option::Option::Some(tmp); + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int32()?; + self.end = ::std::option::Option::Some(tmp); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(v) = self.start { + my_size += ::protobuf::rt::value_size(1, v, ::protobuf::wire_format::WireTypeVarint); + } + if let Some(v) = self.end { + my_size += ::protobuf::rt::value_size(2, v, ::protobuf::wire_format::WireTypeVarint); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(v) = self.start { + os.write_int32(1, v)?; + } + if let Some(v) = self.end { + os.write_int32(2, v)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for DescriptorProto_ReservedRange { + fn new() -> DescriptorProto_ReservedRange { + DescriptorProto_ReservedRange::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "start", + DescriptorProto_ReservedRange::get_start_for_reflect, + DescriptorProto_ReservedRange::mut_start_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "end", + DescriptorProto_ReservedRange::get_end_for_reflect, + DescriptorProto_ReservedRange::mut_end_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "DescriptorProto_ReservedRange", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for DescriptorProto_ReservedRange { + fn clear(&mut self) { + self.clear_start(); + self.clear_end(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for DescriptorProto_ReservedRange { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for DescriptorProto_ReservedRange { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct FieldDescriptorProto { + // message fields + name: ::protobuf::SingularField<::std::string::String>, + number: ::std::option::Option, + label: ::std::option::Option, + field_type: ::std::option::Option, + type_name: ::protobuf::SingularField<::std::string::String>, + extendee: ::protobuf::SingularField<::std::string::String>, + default_value: ::protobuf::SingularField<::std::string::String>, + oneof_index: ::std::option::Option, + json_name: ::protobuf::SingularField<::std::string::String>, + options: ::protobuf::SingularPtrField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for FieldDescriptorProto {} + +impl FieldDescriptorProto { + pub fn new() -> FieldDescriptorProto { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static FieldDescriptorProto { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const FieldDescriptorProto, + }; + unsafe { + instance.get(FieldDescriptorProto::new) + } + } + + // optional string name = 1; + + pub fn clear_name(&mut self) { + self.name.clear(); + } + + pub fn has_name(&self) -> bool { + self.name.is_some() + } + + // Param is passed by value, moved + pub fn set_name(&mut self, v: ::std::string::String) { + self.name = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_name(&mut self) -> &mut ::std::string::String { + if self.name.is_none() { + self.name.set_default(); + } + self.name.as_mut().unwrap() + } + + // Take field + pub fn take_name(&mut self) -> ::std::string::String { + self.name.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_name(&self) -> &str { + match self.name.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_name_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.name + } + + fn mut_name_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.name + } + + // optional int32 number = 3; + + pub fn clear_number(&mut self) { + self.number = ::std::option::Option::None; + } + + pub fn has_number(&self) -> bool { + self.number.is_some() + } + + // Param is passed by value, moved + pub fn set_number(&mut self, v: i32) { + self.number = ::std::option::Option::Some(v); + } + + pub fn get_number(&self) -> i32 { + self.number.unwrap_or(0) + } + + fn get_number_for_reflect(&self) -> &::std::option::Option { + &self.number + } + + fn mut_number_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.number + } + + // optional .google.protobuf.FieldDescriptorProto.Label label = 4; + + pub fn clear_label(&mut self) { + self.label = ::std::option::Option::None; + } + + pub fn has_label(&self) -> bool { + self.label.is_some() + } + + // Param is passed by value, moved + pub fn set_label(&mut self, v: FieldDescriptorProto_Label) { + self.label = ::std::option::Option::Some(v); + } + + pub fn get_label(&self) -> FieldDescriptorProto_Label { + self.label.unwrap_or(FieldDescriptorProto_Label::LABEL_OPTIONAL) + } + + fn get_label_for_reflect(&self) -> &::std::option::Option { + &self.label + } + + fn mut_label_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.label + } + + // optional .google.protobuf.FieldDescriptorProto.Type type = 5; + + pub fn clear_field_type(&mut self) { + self.field_type = ::std::option::Option::None; + } + + pub fn has_field_type(&self) -> bool { + self.field_type.is_some() + } + + // Param is passed by value, moved + pub fn set_field_type(&mut self, v: FieldDescriptorProto_Type) { + self.field_type = ::std::option::Option::Some(v); + } + + pub fn get_field_type(&self) -> FieldDescriptorProto_Type { + self.field_type.unwrap_or(FieldDescriptorProto_Type::TYPE_DOUBLE) + } + + fn get_field_type_for_reflect(&self) -> &::std::option::Option { + &self.field_type + } + + fn mut_field_type_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.field_type + } + + // optional string type_name = 6; + + pub fn clear_type_name(&mut self) { + self.type_name.clear(); + } + + pub fn has_type_name(&self) -> bool { + self.type_name.is_some() + } + + // Param is passed by value, moved + pub fn set_type_name(&mut self, v: ::std::string::String) { + self.type_name = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_type_name(&mut self) -> &mut ::std::string::String { + if self.type_name.is_none() { + self.type_name.set_default(); + } + self.type_name.as_mut().unwrap() + } + + // Take field + pub fn take_type_name(&mut self) -> ::std::string::String { + self.type_name.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_type_name(&self) -> &str { + match self.type_name.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_type_name_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.type_name + } + + fn mut_type_name_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.type_name + } + + // optional string extendee = 2; + + pub fn clear_extendee(&mut self) { + self.extendee.clear(); + } + + pub fn has_extendee(&self) -> bool { + self.extendee.is_some() + } + + // Param is passed by value, moved + pub fn set_extendee(&mut self, v: ::std::string::String) { + self.extendee = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_extendee(&mut self) -> &mut ::std::string::String { + if self.extendee.is_none() { + self.extendee.set_default(); + } + self.extendee.as_mut().unwrap() + } + + // Take field + pub fn take_extendee(&mut self) -> ::std::string::String { + self.extendee.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_extendee(&self) -> &str { + match self.extendee.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_extendee_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.extendee + } + + fn mut_extendee_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.extendee + } + + // optional string default_value = 7; + + pub fn clear_default_value(&mut self) { + self.default_value.clear(); + } + + pub fn has_default_value(&self) -> bool { + self.default_value.is_some() + } + + // Param is passed by value, moved + pub fn set_default_value(&mut self, v: ::std::string::String) { + self.default_value = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_default_value(&mut self) -> &mut ::std::string::String { + if self.default_value.is_none() { + self.default_value.set_default(); + } + self.default_value.as_mut().unwrap() + } + + // Take field + pub fn take_default_value(&mut self) -> ::std::string::String { + self.default_value.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_default_value(&self) -> &str { + match self.default_value.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_default_value_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.default_value + } + + fn mut_default_value_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.default_value + } + + // optional int32 oneof_index = 9; + + pub fn clear_oneof_index(&mut self) { + self.oneof_index = ::std::option::Option::None; + } + + pub fn has_oneof_index(&self) -> bool { + self.oneof_index.is_some() + } + + // Param is passed by value, moved + pub fn set_oneof_index(&mut self, v: i32) { + self.oneof_index = ::std::option::Option::Some(v); + } + + pub fn get_oneof_index(&self) -> i32 { + self.oneof_index.unwrap_or(0) + } + + fn get_oneof_index_for_reflect(&self) -> &::std::option::Option { + &self.oneof_index + } + + fn mut_oneof_index_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.oneof_index + } + + // optional string json_name = 10; + + pub fn clear_json_name(&mut self) { + self.json_name.clear(); + } + + pub fn has_json_name(&self) -> bool { + self.json_name.is_some() + } + + // Param is passed by value, moved + pub fn set_json_name(&mut self, v: ::std::string::String) { + self.json_name = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_json_name(&mut self) -> &mut ::std::string::String { + if self.json_name.is_none() { + self.json_name.set_default(); + } + self.json_name.as_mut().unwrap() + } + + // Take field + pub fn take_json_name(&mut self) -> ::std::string::String { + self.json_name.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_json_name(&self) -> &str { + match self.json_name.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_json_name_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.json_name + } + + fn mut_json_name_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.json_name + } + + // optional .google.protobuf.FieldOptions options = 8; + + pub fn clear_options(&mut self) { + self.options.clear(); + } + + pub fn has_options(&self) -> bool { + self.options.is_some() + } + + // Param is passed by value, moved + pub fn set_options(&mut self, v: FieldOptions) { + self.options = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_options(&mut self) -> &mut FieldOptions { + if self.options.is_none() { + self.options.set_default(); + } + self.options.as_mut().unwrap() + } + + // Take field + pub fn take_options(&mut self) -> FieldOptions { + self.options.take().unwrap_or_else(|| FieldOptions::new()) + } + + pub fn get_options(&self) -> &FieldOptions { + self.options.as_ref().unwrap_or_else(|| FieldOptions::default_instance()) + } + + fn get_options_for_reflect(&self) -> &::protobuf::SingularPtrField { + &self.options + } + + fn mut_options_for_reflect(&mut self) -> &mut ::protobuf::SingularPtrField { + &mut self.options + } +} + +impl ::protobuf::Message for FieldDescriptorProto { + fn is_initialized(&self) -> bool { + for v in &self.options { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.name)?; + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int32()?; + self.number = ::std::option::Option::Some(tmp); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_enum()?; + self.label = ::std::option::Option::Some(tmp); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_enum()?; + self.field_type = ::std::option::Option::Some(tmp); + }, + 6 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.type_name)?; + }, + 2 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.extendee)?; + }, + 7 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.default_value)?; + }, + 9 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int32()?; + self.oneof_index = ::std::option::Option::Some(tmp); + }, + 10 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.json_name)?; + }, + 8 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.options)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.name.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.number { + my_size += ::protobuf::rt::value_size(3, v, ::protobuf::wire_format::WireTypeVarint); + } + if let Some(v) = self.label { + my_size += ::protobuf::rt::enum_size(4, v); + } + if let Some(v) = self.field_type { + my_size += ::protobuf::rt::enum_size(5, v); + } + if let Some(ref v) = self.type_name.as_ref() { + my_size += ::protobuf::rt::string_size(6, &v); + } + if let Some(ref v) = self.extendee.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + if let Some(ref v) = self.default_value.as_ref() { + my_size += ::protobuf::rt::string_size(7, &v); + } + if let Some(v) = self.oneof_index { + my_size += ::protobuf::rt::value_size(9, v, ::protobuf::wire_format::WireTypeVarint); + } + if let Some(ref v) = self.json_name.as_ref() { + my_size += ::protobuf::rt::string_size(10, &v); + } + if let Some(ref v) = self.options.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.name.as_ref() { + os.write_string(1, &v)?; + } + if let Some(v) = self.number { + os.write_int32(3, v)?; + } + if let Some(v) = self.label { + os.write_enum(4, v.value())?; + } + if let Some(v) = self.field_type { + os.write_enum(5, v.value())?; + } + if let Some(ref v) = self.type_name.as_ref() { + os.write_string(6, &v)?; + } + if let Some(ref v) = self.extendee.as_ref() { + os.write_string(2, &v)?; + } + if let Some(ref v) = self.default_value.as_ref() { + os.write_string(7, &v)?; + } + if let Some(v) = self.oneof_index { + os.write_int32(9, v)?; + } + if let Some(ref v) = self.json_name.as_ref() { + os.write_string(10, &v)?; + } + if let Some(ref v) = self.options.as_ref() { + os.write_tag(8, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for FieldDescriptorProto { + fn new() -> FieldDescriptorProto { + FieldDescriptorProto::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "name", + FieldDescriptorProto::get_name_for_reflect, + FieldDescriptorProto::mut_name_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "number", + FieldDescriptorProto::get_number_for_reflect, + FieldDescriptorProto::mut_number_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( + "label", + FieldDescriptorProto::get_label_for_reflect, + FieldDescriptorProto::mut_label_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( + "type", + FieldDescriptorProto::get_field_type_for_reflect, + FieldDescriptorProto::mut_field_type_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "type_name", + FieldDescriptorProto::get_type_name_for_reflect, + FieldDescriptorProto::mut_type_name_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "extendee", + FieldDescriptorProto::get_extendee_for_reflect, + FieldDescriptorProto::mut_extendee_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "default_value", + FieldDescriptorProto::get_default_value_for_reflect, + FieldDescriptorProto::mut_default_value_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "oneof_index", + FieldDescriptorProto::get_oneof_index_for_reflect, + FieldDescriptorProto::mut_oneof_index_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "json_name", + FieldDescriptorProto::get_json_name_for_reflect, + FieldDescriptorProto::mut_json_name_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "options", + FieldDescriptorProto::get_options_for_reflect, + FieldDescriptorProto::mut_options_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "FieldDescriptorProto", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for FieldDescriptorProto { + fn clear(&mut self) { + self.clear_name(); + self.clear_number(); + self.clear_label(); + self.clear_field_type(); + self.clear_type_name(); + self.clear_extendee(); + self.clear_default_value(); + self.clear_oneof_index(); + self.clear_json_name(); + self.clear_options(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for FieldDescriptorProto { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for FieldDescriptorProto { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum FieldDescriptorProto_Type { + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + TYPE_GROUP = 10, + TYPE_MESSAGE = 11, + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + TYPE_SINT32 = 17, + TYPE_SINT64 = 18, +} + +impl ::protobuf::ProtobufEnum for FieldDescriptorProto_Type { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 1 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_DOUBLE), + 2 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_FLOAT), + 3 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_INT64), + 4 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_UINT64), + 5 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_INT32), + 6 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_FIXED64), + 7 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_FIXED32), + 8 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_BOOL), + 9 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_STRING), + 10 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_GROUP), + 11 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_MESSAGE), + 12 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_BYTES), + 13 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_UINT32), + 14 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_ENUM), + 15 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_SFIXED32), + 16 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_SFIXED64), + 17 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_SINT32), + 18 => ::std::option::Option::Some(FieldDescriptorProto_Type::TYPE_SINT64), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [FieldDescriptorProto_Type] = &[ + FieldDescriptorProto_Type::TYPE_DOUBLE, + FieldDescriptorProto_Type::TYPE_FLOAT, + FieldDescriptorProto_Type::TYPE_INT64, + FieldDescriptorProto_Type::TYPE_UINT64, + FieldDescriptorProto_Type::TYPE_INT32, + FieldDescriptorProto_Type::TYPE_FIXED64, + FieldDescriptorProto_Type::TYPE_FIXED32, + FieldDescriptorProto_Type::TYPE_BOOL, + FieldDescriptorProto_Type::TYPE_STRING, + FieldDescriptorProto_Type::TYPE_GROUP, + FieldDescriptorProto_Type::TYPE_MESSAGE, + FieldDescriptorProto_Type::TYPE_BYTES, + FieldDescriptorProto_Type::TYPE_UINT32, + FieldDescriptorProto_Type::TYPE_ENUM, + FieldDescriptorProto_Type::TYPE_SFIXED32, + FieldDescriptorProto_Type::TYPE_SFIXED64, + FieldDescriptorProto_Type::TYPE_SINT32, + FieldDescriptorProto_Type::TYPE_SINT64, + ]; + values + } + + fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, + }; + unsafe { + descriptor.get(|| { + ::protobuf::reflect::EnumDescriptor::new("FieldDescriptorProto_Type", file_descriptor_proto()) + }) + } + } +} + +impl ::std::marker::Copy for FieldDescriptorProto_Type { +} + +impl ::protobuf::reflect::ProtobufValue for FieldDescriptorProto_Type { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) + } +} + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum FieldDescriptorProto_Label { + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, +} + +impl ::protobuf::ProtobufEnum for FieldDescriptorProto_Label { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 1 => ::std::option::Option::Some(FieldDescriptorProto_Label::LABEL_OPTIONAL), + 2 => ::std::option::Option::Some(FieldDescriptorProto_Label::LABEL_REQUIRED), + 3 => ::std::option::Option::Some(FieldDescriptorProto_Label::LABEL_REPEATED), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [FieldDescriptorProto_Label] = &[ + FieldDescriptorProto_Label::LABEL_OPTIONAL, + FieldDescriptorProto_Label::LABEL_REQUIRED, + FieldDescriptorProto_Label::LABEL_REPEATED, + ]; + values + } + + fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, + }; + unsafe { + descriptor.get(|| { + ::protobuf::reflect::EnumDescriptor::new("FieldDescriptorProto_Label", file_descriptor_proto()) + }) + } + } +} + +impl ::std::marker::Copy for FieldDescriptorProto_Label { +} + +impl ::protobuf::reflect::ProtobufValue for FieldDescriptorProto_Label { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct OneofDescriptorProto { + // message fields + name: ::protobuf::SingularField<::std::string::String>, + options: ::protobuf::SingularPtrField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for OneofDescriptorProto {} + +impl OneofDescriptorProto { + pub fn new() -> OneofDescriptorProto { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static OneofDescriptorProto { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const OneofDescriptorProto, + }; + unsafe { + instance.get(OneofDescriptorProto::new) + } + } + + // optional string name = 1; + + pub fn clear_name(&mut self) { + self.name.clear(); + } + + pub fn has_name(&self) -> bool { + self.name.is_some() + } + + // Param is passed by value, moved + pub fn set_name(&mut self, v: ::std::string::String) { + self.name = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_name(&mut self) -> &mut ::std::string::String { + if self.name.is_none() { + self.name.set_default(); + } + self.name.as_mut().unwrap() + } + + // Take field + pub fn take_name(&mut self) -> ::std::string::String { + self.name.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_name(&self) -> &str { + match self.name.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_name_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.name + } + + fn mut_name_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.name + } + + // optional .google.protobuf.OneofOptions options = 2; + + pub fn clear_options(&mut self) { + self.options.clear(); + } + + pub fn has_options(&self) -> bool { + self.options.is_some() + } + + // Param is passed by value, moved + pub fn set_options(&mut self, v: OneofOptions) { + self.options = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_options(&mut self) -> &mut OneofOptions { + if self.options.is_none() { + self.options.set_default(); + } + self.options.as_mut().unwrap() + } + + // Take field + pub fn take_options(&mut self) -> OneofOptions { + self.options.take().unwrap_or_else(|| OneofOptions::new()) + } + + pub fn get_options(&self) -> &OneofOptions { + self.options.as_ref().unwrap_or_else(|| OneofOptions::default_instance()) + } + + fn get_options_for_reflect(&self) -> &::protobuf::SingularPtrField { + &self.options + } + + fn mut_options_for_reflect(&mut self) -> &mut ::protobuf::SingularPtrField { + &mut self.options + } +} + +impl ::protobuf::Message for OneofDescriptorProto { + fn is_initialized(&self) -> bool { + for v in &self.options { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.name)?; + }, + 2 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.options)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.name.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(ref v) = self.options.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.name.as_ref() { + os.write_string(1, &v)?; + } + if let Some(ref v) = self.options.as_ref() { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for OneofDescriptorProto { + fn new() -> OneofDescriptorProto { + OneofDescriptorProto::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "name", + OneofDescriptorProto::get_name_for_reflect, + OneofDescriptorProto::mut_name_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "options", + OneofDescriptorProto::get_options_for_reflect, + OneofDescriptorProto::mut_options_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "OneofDescriptorProto", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for OneofDescriptorProto { + fn clear(&mut self) { + self.clear_name(); + self.clear_options(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for OneofDescriptorProto { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for OneofDescriptorProto { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct EnumDescriptorProto { + // message fields + name: ::protobuf::SingularField<::std::string::String>, + value: ::protobuf::RepeatedField, + options: ::protobuf::SingularPtrField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for EnumDescriptorProto {} + +impl EnumDescriptorProto { + pub fn new() -> EnumDescriptorProto { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static EnumDescriptorProto { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const EnumDescriptorProto, + }; + unsafe { + instance.get(EnumDescriptorProto::new) + } + } + + // optional string name = 1; + + pub fn clear_name(&mut self) { + self.name.clear(); + } + + pub fn has_name(&self) -> bool { + self.name.is_some() + } + + // Param is passed by value, moved + pub fn set_name(&mut self, v: ::std::string::String) { + self.name = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_name(&mut self) -> &mut ::std::string::String { + if self.name.is_none() { + self.name.set_default(); + } + self.name.as_mut().unwrap() + } + + // Take field + pub fn take_name(&mut self) -> ::std::string::String { + self.name.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_name(&self) -> &str { + match self.name.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_name_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.name + } + + fn mut_name_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.name + } + + // repeated .google.protobuf.EnumValueDescriptorProto value = 2; + + pub fn clear_value(&mut self) { + self.value.clear(); + } + + // Param is passed by value, moved + pub fn set_value(&mut self, v: ::protobuf::RepeatedField) { + self.value = v; + } + + // Mutable pointer to the field. + pub fn mut_value(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.value + } + + // Take field + pub fn take_value(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.value, ::protobuf::RepeatedField::new()) + } + + pub fn get_value(&self) -> &[EnumValueDescriptorProto] { + &self.value + } + + fn get_value_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.value + } + + fn mut_value_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.value + } + + // optional .google.protobuf.EnumOptions options = 3; + + pub fn clear_options(&mut self) { + self.options.clear(); + } + + pub fn has_options(&self) -> bool { + self.options.is_some() + } + + // Param is passed by value, moved + pub fn set_options(&mut self, v: EnumOptions) { + self.options = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_options(&mut self) -> &mut EnumOptions { + if self.options.is_none() { + self.options.set_default(); + } + self.options.as_mut().unwrap() + } + + // Take field + pub fn take_options(&mut self) -> EnumOptions { + self.options.take().unwrap_or_else(|| EnumOptions::new()) + } + + pub fn get_options(&self) -> &EnumOptions { + self.options.as_ref().unwrap_or_else(|| EnumOptions::default_instance()) + } + + fn get_options_for_reflect(&self) -> &::protobuf::SingularPtrField { + &self.options + } + + fn mut_options_for_reflect(&mut self) -> &mut ::protobuf::SingularPtrField { + &mut self.options + } +} + +impl ::protobuf::Message for EnumDescriptorProto { + fn is_initialized(&self) -> bool { + for v in &self.value { + if !v.is_initialized() { + return false; + } + }; + for v in &self.options { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.name)?; + }, + 2 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.value)?; + }, + 3 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.options)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.name.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + for value in &self.value { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + if let Some(ref v) = self.options.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.name.as_ref() { + os.write_string(1, &v)?; + } + for v in &self.value { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + if let Some(ref v) = self.options.as_ref() { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for EnumDescriptorProto { + fn new() -> EnumDescriptorProto { + EnumDescriptorProto::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "name", + EnumDescriptorProto::get_name_for_reflect, + EnumDescriptorProto::mut_name_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "value", + EnumDescriptorProto::get_value_for_reflect, + EnumDescriptorProto::mut_value_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "options", + EnumDescriptorProto::get_options_for_reflect, + EnumDescriptorProto::mut_options_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "EnumDescriptorProto", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for EnumDescriptorProto { + fn clear(&mut self) { + self.clear_name(); + self.clear_value(); + self.clear_options(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for EnumDescriptorProto { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for EnumDescriptorProto { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct EnumValueDescriptorProto { + // message fields + name: ::protobuf::SingularField<::std::string::String>, + number: ::std::option::Option, + options: ::protobuf::SingularPtrField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for EnumValueDescriptorProto {} + +impl EnumValueDescriptorProto { + pub fn new() -> EnumValueDescriptorProto { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static EnumValueDescriptorProto { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const EnumValueDescriptorProto, + }; + unsafe { + instance.get(EnumValueDescriptorProto::new) + } + } + + // optional string name = 1; + + pub fn clear_name(&mut self) { + self.name.clear(); + } + + pub fn has_name(&self) -> bool { + self.name.is_some() + } + + // Param is passed by value, moved + pub fn set_name(&mut self, v: ::std::string::String) { + self.name = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_name(&mut self) -> &mut ::std::string::String { + if self.name.is_none() { + self.name.set_default(); + } + self.name.as_mut().unwrap() + } + + // Take field + pub fn take_name(&mut self) -> ::std::string::String { + self.name.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_name(&self) -> &str { + match self.name.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_name_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.name + } + + fn mut_name_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.name + } + + // optional int32 number = 2; + + pub fn clear_number(&mut self) { + self.number = ::std::option::Option::None; + } + + pub fn has_number(&self) -> bool { + self.number.is_some() + } + + // Param is passed by value, moved + pub fn set_number(&mut self, v: i32) { + self.number = ::std::option::Option::Some(v); + } + + pub fn get_number(&self) -> i32 { + self.number.unwrap_or(0) + } + + fn get_number_for_reflect(&self) -> &::std::option::Option { + &self.number + } + + fn mut_number_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.number + } + + // optional .google.protobuf.EnumValueOptions options = 3; + + pub fn clear_options(&mut self) { + self.options.clear(); + } + + pub fn has_options(&self) -> bool { + self.options.is_some() + } + + // Param is passed by value, moved + pub fn set_options(&mut self, v: EnumValueOptions) { + self.options = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_options(&mut self) -> &mut EnumValueOptions { + if self.options.is_none() { + self.options.set_default(); + } + self.options.as_mut().unwrap() + } + + // Take field + pub fn take_options(&mut self) -> EnumValueOptions { + self.options.take().unwrap_or_else(|| EnumValueOptions::new()) + } + + pub fn get_options(&self) -> &EnumValueOptions { + self.options.as_ref().unwrap_or_else(|| EnumValueOptions::default_instance()) + } + + fn get_options_for_reflect(&self) -> &::protobuf::SingularPtrField { + &self.options + } + + fn mut_options_for_reflect(&mut self) -> &mut ::protobuf::SingularPtrField { + &mut self.options + } +} + +impl ::protobuf::Message for EnumValueDescriptorProto { + fn is_initialized(&self) -> bool { + for v in &self.options { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.name)?; + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int32()?; + self.number = ::std::option::Option::Some(tmp); + }, + 3 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.options)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.name.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.number { + my_size += ::protobuf::rt::value_size(2, v, ::protobuf::wire_format::WireTypeVarint); + } + if let Some(ref v) = self.options.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.name.as_ref() { + os.write_string(1, &v)?; + } + if let Some(v) = self.number { + os.write_int32(2, v)?; + } + if let Some(ref v) = self.options.as_ref() { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for EnumValueDescriptorProto { + fn new() -> EnumValueDescriptorProto { + EnumValueDescriptorProto::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "name", + EnumValueDescriptorProto::get_name_for_reflect, + EnumValueDescriptorProto::mut_name_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "number", + EnumValueDescriptorProto::get_number_for_reflect, + EnumValueDescriptorProto::mut_number_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "options", + EnumValueDescriptorProto::get_options_for_reflect, + EnumValueDescriptorProto::mut_options_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "EnumValueDescriptorProto", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for EnumValueDescriptorProto { + fn clear(&mut self) { + self.clear_name(); + self.clear_number(); + self.clear_options(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for EnumValueDescriptorProto { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for EnumValueDescriptorProto { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct ServiceDescriptorProto { + // message fields + name: ::protobuf::SingularField<::std::string::String>, + method: ::protobuf::RepeatedField, + options: ::protobuf::SingularPtrField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for ServiceDescriptorProto {} + +impl ServiceDescriptorProto { + pub fn new() -> ServiceDescriptorProto { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static ServiceDescriptorProto { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ServiceDescriptorProto, + }; + unsafe { + instance.get(ServiceDescriptorProto::new) + } + } + + // optional string name = 1; + + pub fn clear_name(&mut self) { + self.name.clear(); + } + + pub fn has_name(&self) -> bool { + self.name.is_some() + } + + // Param is passed by value, moved + pub fn set_name(&mut self, v: ::std::string::String) { + self.name = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_name(&mut self) -> &mut ::std::string::String { + if self.name.is_none() { + self.name.set_default(); + } + self.name.as_mut().unwrap() + } + + // Take field + pub fn take_name(&mut self) -> ::std::string::String { + self.name.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_name(&self) -> &str { + match self.name.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_name_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.name + } + + fn mut_name_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.name + } + + // repeated .google.protobuf.MethodDescriptorProto method = 2; + + pub fn clear_method(&mut self) { + self.method.clear(); + } + + // Param is passed by value, moved + pub fn set_method(&mut self, v: ::protobuf::RepeatedField) { + self.method = v; + } + + // Mutable pointer to the field. + pub fn mut_method(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.method + } + + // Take field + pub fn take_method(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.method, ::protobuf::RepeatedField::new()) + } + + pub fn get_method(&self) -> &[MethodDescriptorProto] { + &self.method + } + + fn get_method_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.method + } + + fn mut_method_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.method + } + + // optional .google.protobuf.ServiceOptions options = 3; + + pub fn clear_options(&mut self) { + self.options.clear(); + } + + pub fn has_options(&self) -> bool { + self.options.is_some() + } + + // Param is passed by value, moved + pub fn set_options(&mut self, v: ServiceOptions) { + self.options = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_options(&mut self) -> &mut ServiceOptions { + if self.options.is_none() { + self.options.set_default(); + } + self.options.as_mut().unwrap() + } + + // Take field + pub fn take_options(&mut self) -> ServiceOptions { + self.options.take().unwrap_or_else(|| ServiceOptions::new()) + } + + pub fn get_options(&self) -> &ServiceOptions { + self.options.as_ref().unwrap_or_else(|| ServiceOptions::default_instance()) + } + + fn get_options_for_reflect(&self) -> &::protobuf::SingularPtrField { + &self.options + } + + fn mut_options_for_reflect(&mut self) -> &mut ::protobuf::SingularPtrField { + &mut self.options + } +} + +impl ::protobuf::Message for ServiceDescriptorProto { + fn is_initialized(&self) -> bool { + for v in &self.method { + if !v.is_initialized() { + return false; + } + }; + for v in &self.options { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.name)?; + }, + 2 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.method)?; + }, + 3 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.options)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.name.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + for value in &self.method { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + if let Some(ref v) = self.options.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.name.as_ref() { + os.write_string(1, &v)?; + } + for v in &self.method { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + if let Some(ref v) = self.options.as_ref() { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for ServiceDescriptorProto { + fn new() -> ServiceDescriptorProto { + ServiceDescriptorProto::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "name", + ServiceDescriptorProto::get_name_for_reflect, + ServiceDescriptorProto::mut_name_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "method", + ServiceDescriptorProto::get_method_for_reflect, + ServiceDescriptorProto::mut_method_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "options", + ServiceDescriptorProto::get_options_for_reflect, + ServiceDescriptorProto::mut_options_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "ServiceDescriptorProto", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for ServiceDescriptorProto { + fn clear(&mut self) { + self.clear_name(); + self.clear_method(); + self.clear_options(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for ServiceDescriptorProto { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for ServiceDescriptorProto { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct MethodDescriptorProto { + // message fields + name: ::protobuf::SingularField<::std::string::String>, + input_type: ::protobuf::SingularField<::std::string::String>, + output_type: ::protobuf::SingularField<::std::string::String>, + options: ::protobuf::SingularPtrField, + client_streaming: ::std::option::Option, + server_streaming: ::std::option::Option, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for MethodDescriptorProto {} + +impl MethodDescriptorProto { + pub fn new() -> MethodDescriptorProto { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static MethodDescriptorProto { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const MethodDescriptorProto, + }; + unsafe { + instance.get(MethodDescriptorProto::new) + } + } + + // optional string name = 1; + + pub fn clear_name(&mut self) { + self.name.clear(); + } + + pub fn has_name(&self) -> bool { + self.name.is_some() + } + + // Param is passed by value, moved + pub fn set_name(&mut self, v: ::std::string::String) { + self.name = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_name(&mut self) -> &mut ::std::string::String { + if self.name.is_none() { + self.name.set_default(); + } + self.name.as_mut().unwrap() + } + + // Take field + pub fn take_name(&mut self) -> ::std::string::String { + self.name.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_name(&self) -> &str { + match self.name.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_name_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.name + } + + fn mut_name_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.name + } + + // optional string input_type = 2; + + pub fn clear_input_type(&mut self) { + self.input_type.clear(); + } + + pub fn has_input_type(&self) -> bool { + self.input_type.is_some() + } + + // Param is passed by value, moved + pub fn set_input_type(&mut self, v: ::std::string::String) { + self.input_type = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_input_type(&mut self) -> &mut ::std::string::String { + if self.input_type.is_none() { + self.input_type.set_default(); + } + self.input_type.as_mut().unwrap() + } + + // Take field + pub fn take_input_type(&mut self) -> ::std::string::String { + self.input_type.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_input_type(&self) -> &str { + match self.input_type.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_input_type_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.input_type + } + + fn mut_input_type_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.input_type + } + + // optional string output_type = 3; + + pub fn clear_output_type(&mut self) { + self.output_type.clear(); + } + + pub fn has_output_type(&self) -> bool { + self.output_type.is_some() + } + + // Param is passed by value, moved + pub fn set_output_type(&mut self, v: ::std::string::String) { + self.output_type = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_output_type(&mut self) -> &mut ::std::string::String { + if self.output_type.is_none() { + self.output_type.set_default(); + } + self.output_type.as_mut().unwrap() + } + + // Take field + pub fn take_output_type(&mut self) -> ::std::string::String { + self.output_type.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_output_type(&self) -> &str { + match self.output_type.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_output_type_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.output_type + } + + fn mut_output_type_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.output_type + } + + // optional .google.protobuf.MethodOptions options = 4; + + pub fn clear_options(&mut self) { + self.options.clear(); + } + + pub fn has_options(&self) -> bool { + self.options.is_some() + } + + // Param is passed by value, moved + pub fn set_options(&mut self, v: MethodOptions) { + self.options = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_options(&mut self) -> &mut MethodOptions { + if self.options.is_none() { + self.options.set_default(); + } + self.options.as_mut().unwrap() + } + + // Take field + pub fn take_options(&mut self) -> MethodOptions { + self.options.take().unwrap_or_else(|| MethodOptions::new()) + } + + pub fn get_options(&self) -> &MethodOptions { + self.options.as_ref().unwrap_or_else(|| MethodOptions::default_instance()) + } + + fn get_options_for_reflect(&self) -> &::protobuf::SingularPtrField { + &self.options + } + + fn mut_options_for_reflect(&mut self) -> &mut ::protobuf::SingularPtrField { + &mut self.options + } + + // optional bool client_streaming = 5; + + pub fn clear_client_streaming(&mut self) { + self.client_streaming = ::std::option::Option::None; + } + + pub fn has_client_streaming(&self) -> bool { + self.client_streaming.is_some() + } + + // Param is passed by value, moved + pub fn set_client_streaming(&mut self, v: bool) { + self.client_streaming = ::std::option::Option::Some(v); + } + + pub fn get_client_streaming(&self) -> bool { + self.client_streaming.unwrap_or(false) + } + + fn get_client_streaming_for_reflect(&self) -> &::std::option::Option { + &self.client_streaming + } + + fn mut_client_streaming_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.client_streaming + } + + // optional bool server_streaming = 6; + + pub fn clear_server_streaming(&mut self) { + self.server_streaming = ::std::option::Option::None; + } + + pub fn has_server_streaming(&self) -> bool { + self.server_streaming.is_some() + } + + // Param is passed by value, moved + pub fn set_server_streaming(&mut self, v: bool) { + self.server_streaming = ::std::option::Option::Some(v); + } + + pub fn get_server_streaming(&self) -> bool { + self.server_streaming.unwrap_or(false) + } + + fn get_server_streaming_for_reflect(&self) -> &::std::option::Option { + &self.server_streaming + } + + fn mut_server_streaming_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.server_streaming + } +} + +impl ::protobuf::Message for MethodDescriptorProto { + fn is_initialized(&self) -> bool { + for v in &self.options { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.name)?; + }, + 2 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.input_type)?; + }, + 3 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.output_type)?; + }, + 4 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.options)?; + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.client_streaming = ::std::option::Option::Some(tmp); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.server_streaming = ::std::option::Option::Some(tmp); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.name.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(ref v) = self.input_type.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + if let Some(ref v) = self.output_type.as_ref() { + my_size += ::protobuf::rt::string_size(3, &v); + } + if let Some(ref v) = self.options.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + if let Some(v) = self.client_streaming { + my_size += 2; + } + if let Some(v) = self.server_streaming { + my_size += 2; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.name.as_ref() { + os.write_string(1, &v)?; + } + if let Some(ref v) = self.input_type.as_ref() { + os.write_string(2, &v)?; + } + if let Some(ref v) = self.output_type.as_ref() { + os.write_string(3, &v)?; + } + if let Some(ref v) = self.options.as_ref() { + os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + if let Some(v) = self.client_streaming { + os.write_bool(5, v)?; + } + if let Some(v) = self.server_streaming { + os.write_bool(6, v)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for MethodDescriptorProto { + fn new() -> MethodDescriptorProto { + MethodDescriptorProto::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "name", + MethodDescriptorProto::get_name_for_reflect, + MethodDescriptorProto::mut_name_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "input_type", + MethodDescriptorProto::get_input_type_for_reflect, + MethodDescriptorProto::mut_input_type_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "output_type", + MethodDescriptorProto::get_output_type_for_reflect, + MethodDescriptorProto::mut_output_type_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "options", + MethodDescriptorProto::get_options_for_reflect, + MethodDescriptorProto::mut_options_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "client_streaming", + MethodDescriptorProto::get_client_streaming_for_reflect, + MethodDescriptorProto::mut_client_streaming_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "server_streaming", + MethodDescriptorProto::get_server_streaming_for_reflect, + MethodDescriptorProto::mut_server_streaming_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "MethodDescriptorProto", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for MethodDescriptorProto { + fn clear(&mut self) { + self.clear_name(); + self.clear_input_type(); + self.clear_output_type(); + self.clear_options(); + self.clear_client_streaming(); + self.clear_server_streaming(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for MethodDescriptorProto { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MethodDescriptorProto { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct FileOptions { + // message fields + java_package: ::protobuf::SingularField<::std::string::String>, + java_outer_classname: ::protobuf::SingularField<::std::string::String>, + java_multiple_files: ::std::option::Option, + java_generate_equals_and_hash: ::std::option::Option, + java_string_check_utf8: ::std::option::Option, + optimize_for: ::std::option::Option, + go_package: ::protobuf::SingularField<::std::string::String>, + cc_generic_services: ::std::option::Option, + java_generic_services: ::std::option::Option, + py_generic_services: ::std::option::Option, + deprecated: ::std::option::Option, + cc_enable_arenas: ::std::option::Option, + objc_class_prefix: ::protobuf::SingularField<::std::string::String>, + csharp_namespace: ::protobuf::SingularField<::std::string::String>, + uninterpreted_option: ::protobuf::RepeatedField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for FileOptions {} + +impl FileOptions { + pub fn new() -> FileOptions { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static FileOptions { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const FileOptions, + }; + unsafe { + instance.get(FileOptions::new) + } + } + + // optional string java_package = 1; + + pub fn clear_java_package(&mut self) { + self.java_package.clear(); + } + + pub fn has_java_package(&self) -> bool { + self.java_package.is_some() + } + + // Param is passed by value, moved + pub fn set_java_package(&mut self, v: ::std::string::String) { + self.java_package = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_java_package(&mut self) -> &mut ::std::string::String { + if self.java_package.is_none() { + self.java_package.set_default(); + } + self.java_package.as_mut().unwrap() + } + + // Take field + pub fn take_java_package(&mut self) -> ::std::string::String { + self.java_package.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_java_package(&self) -> &str { + match self.java_package.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_java_package_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.java_package + } + + fn mut_java_package_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.java_package + } + + // optional string java_outer_classname = 8; + + pub fn clear_java_outer_classname(&mut self) { + self.java_outer_classname.clear(); + } + + pub fn has_java_outer_classname(&self) -> bool { + self.java_outer_classname.is_some() + } + + // Param is passed by value, moved + pub fn set_java_outer_classname(&mut self, v: ::std::string::String) { + self.java_outer_classname = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_java_outer_classname(&mut self) -> &mut ::std::string::String { + if self.java_outer_classname.is_none() { + self.java_outer_classname.set_default(); + } + self.java_outer_classname.as_mut().unwrap() + } + + // Take field + pub fn take_java_outer_classname(&mut self) -> ::std::string::String { + self.java_outer_classname.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_java_outer_classname(&self) -> &str { + match self.java_outer_classname.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_java_outer_classname_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.java_outer_classname + } + + fn mut_java_outer_classname_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.java_outer_classname + } + + // optional bool java_multiple_files = 10; + + pub fn clear_java_multiple_files(&mut self) { + self.java_multiple_files = ::std::option::Option::None; + } + + pub fn has_java_multiple_files(&self) -> bool { + self.java_multiple_files.is_some() + } + + // Param is passed by value, moved + pub fn set_java_multiple_files(&mut self, v: bool) { + self.java_multiple_files = ::std::option::Option::Some(v); + } + + pub fn get_java_multiple_files(&self) -> bool { + self.java_multiple_files.unwrap_or(false) + } + + fn get_java_multiple_files_for_reflect(&self) -> &::std::option::Option { + &self.java_multiple_files + } + + fn mut_java_multiple_files_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.java_multiple_files + } + + // optional bool java_generate_equals_and_hash = 20; + + pub fn clear_java_generate_equals_and_hash(&mut self) { + self.java_generate_equals_and_hash = ::std::option::Option::None; + } + + pub fn has_java_generate_equals_and_hash(&self) -> bool { + self.java_generate_equals_and_hash.is_some() + } + + // Param is passed by value, moved + pub fn set_java_generate_equals_and_hash(&mut self, v: bool) { + self.java_generate_equals_and_hash = ::std::option::Option::Some(v); + } + + pub fn get_java_generate_equals_and_hash(&self) -> bool { + self.java_generate_equals_and_hash.unwrap_or(false) + } + + fn get_java_generate_equals_and_hash_for_reflect(&self) -> &::std::option::Option { + &self.java_generate_equals_and_hash + } + + fn mut_java_generate_equals_and_hash_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.java_generate_equals_and_hash + } + + // optional bool java_string_check_utf8 = 27; + + pub fn clear_java_string_check_utf8(&mut self) { + self.java_string_check_utf8 = ::std::option::Option::None; + } + + pub fn has_java_string_check_utf8(&self) -> bool { + self.java_string_check_utf8.is_some() + } + + // Param is passed by value, moved + pub fn set_java_string_check_utf8(&mut self, v: bool) { + self.java_string_check_utf8 = ::std::option::Option::Some(v); + } + + pub fn get_java_string_check_utf8(&self) -> bool { + self.java_string_check_utf8.unwrap_or(false) + } + + fn get_java_string_check_utf8_for_reflect(&self) -> &::std::option::Option { + &self.java_string_check_utf8 + } + + fn mut_java_string_check_utf8_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.java_string_check_utf8 + } + + // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9; + + pub fn clear_optimize_for(&mut self) { + self.optimize_for = ::std::option::Option::None; + } + + pub fn has_optimize_for(&self) -> bool { + self.optimize_for.is_some() + } + + // Param is passed by value, moved + pub fn set_optimize_for(&mut self, v: FileOptions_OptimizeMode) { + self.optimize_for = ::std::option::Option::Some(v); + } + + pub fn get_optimize_for(&self) -> FileOptions_OptimizeMode { + self.optimize_for.unwrap_or(FileOptions_OptimizeMode::SPEED) + } + + fn get_optimize_for_for_reflect(&self) -> &::std::option::Option { + &self.optimize_for + } + + fn mut_optimize_for_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.optimize_for + } + + // optional string go_package = 11; + + pub fn clear_go_package(&mut self) { + self.go_package.clear(); + } + + pub fn has_go_package(&self) -> bool { + self.go_package.is_some() + } + + // Param is passed by value, moved + pub fn set_go_package(&mut self, v: ::std::string::String) { + self.go_package = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_go_package(&mut self) -> &mut ::std::string::String { + if self.go_package.is_none() { + self.go_package.set_default(); + } + self.go_package.as_mut().unwrap() + } + + // Take field + pub fn take_go_package(&mut self) -> ::std::string::String { + self.go_package.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_go_package(&self) -> &str { + match self.go_package.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_go_package_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.go_package + } + + fn mut_go_package_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.go_package + } + + // optional bool cc_generic_services = 16; + + pub fn clear_cc_generic_services(&mut self) { + self.cc_generic_services = ::std::option::Option::None; + } + + pub fn has_cc_generic_services(&self) -> bool { + self.cc_generic_services.is_some() + } + + // Param is passed by value, moved + pub fn set_cc_generic_services(&mut self, v: bool) { + self.cc_generic_services = ::std::option::Option::Some(v); + } + + pub fn get_cc_generic_services(&self) -> bool { + self.cc_generic_services.unwrap_or(false) + } + + fn get_cc_generic_services_for_reflect(&self) -> &::std::option::Option { + &self.cc_generic_services + } + + fn mut_cc_generic_services_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.cc_generic_services + } + + // optional bool java_generic_services = 17; + + pub fn clear_java_generic_services(&mut self) { + self.java_generic_services = ::std::option::Option::None; + } + + pub fn has_java_generic_services(&self) -> bool { + self.java_generic_services.is_some() + } + + // Param is passed by value, moved + pub fn set_java_generic_services(&mut self, v: bool) { + self.java_generic_services = ::std::option::Option::Some(v); + } + + pub fn get_java_generic_services(&self) -> bool { + self.java_generic_services.unwrap_or(false) + } + + fn get_java_generic_services_for_reflect(&self) -> &::std::option::Option { + &self.java_generic_services + } + + fn mut_java_generic_services_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.java_generic_services + } + + // optional bool py_generic_services = 18; + + pub fn clear_py_generic_services(&mut self) { + self.py_generic_services = ::std::option::Option::None; + } + + pub fn has_py_generic_services(&self) -> bool { + self.py_generic_services.is_some() + } + + // Param is passed by value, moved + pub fn set_py_generic_services(&mut self, v: bool) { + self.py_generic_services = ::std::option::Option::Some(v); + } + + pub fn get_py_generic_services(&self) -> bool { + self.py_generic_services.unwrap_or(false) + } + + fn get_py_generic_services_for_reflect(&self) -> &::std::option::Option { + &self.py_generic_services + } + + fn mut_py_generic_services_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.py_generic_services + } + + // optional bool deprecated = 23; + + pub fn clear_deprecated(&mut self) { + self.deprecated = ::std::option::Option::None; + } + + pub fn has_deprecated(&self) -> bool { + self.deprecated.is_some() + } + + // Param is passed by value, moved + pub fn set_deprecated(&mut self, v: bool) { + self.deprecated = ::std::option::Option::Some(v); + } + + pub fn get_deprecated(&self) -> bool { + self.deprecated.unwrap_or(false) + } + + fn get_deprecated_for_reflect(&self) -> &::std::option::Option { + &self.deprecated + } + + fn mut_deprecated_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.deprecated + } + + // optional bool cc_enable_arenas = 31; + + pub fn clear_cc_enable_arenas(&mut self) { + self.cc_enable_arenas = ::std::option::Option::None; + } + + pub fn has_cc_enable_arenas(&self) -> bool { + self.cc_enable_arenas.is_some() + } + + // Param is passed by value, moved + pub fn set_cc_enable_arenas(&mut self, v: bool) { + self.cc_enable_arenas = ::std::option::Option::Some(v); + } + + pub fn get_cc_enable_arenas(&self) -> bool { + self.cc_enable_arenas.unwrap_or(false) + } + + fn get_cc_enable_arenas_for_reflect(&self) -> &::std::option::Option { + &self.cc_enable_arenas + } + + fn mut_cc_enable_arenas_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.cc_enable_arenas + } + + // optional string objc_class_prefix = 36; + + pub fn clear_objc_class_prefix(&mut self) { + self.objc_class_prefix.clear(); + } + + pub fn has_objc_class_prefix(&self) -> bool { + self.objc_class_prefix.is_some() + } + + // Param is passed by value, moved + pub fn set_objc_class_prefix(&mut self, v: ::std::string::String) { + self.objc_class_prefix = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_objc_class_prefix(&mut self) -> &mut ::std::string::String { + if self.objc_class_prefix.is_none() { + self.objc_class_prefix.set_default(); + } + self.objc_class_prefix.as_mut().unwrap() + } + + // Take field + pub fn take_objc_class_prefix(&mut self) -> ::std::string::String { + self.objc_class_prefix.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_objc_class_prefix(&self) -> &str { + match self.objc_class_prefix.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_objc_class_prefix_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.objc_class_prefix + } + + fn mut_objc_class_prefix_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.objc_class_prefix + } + + // optional string csharp_namespace = 37; + + pub fn clear_csharp_namespace(&mut self) { + self.csharp_namespace.clear(); + } + + pub fn has_csharp_namespace(&self) -> bool { + self.csharp_namespace.is_some() + } + + // Param is passed by value, moved + pub fn set_csharp_namespace(&mut self, v: ::std::string::String) { + self.csharp_namespace = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_csharp_namespace(&mut self) -> &mut ::std::string::String { + if self.csharp_namespace.is_none() { + self.csharp_namespace.set_default(); + } + self.csharp_namespace.as_mut().unwrap() + } + + // Take field + pub fn take_csharp_namespace(&mut self) -> ::std::string::String { + self.csharp_namespace.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_csharp_namespace(&self) -> &str { + match self.csharp_namespace.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_csharp_namespace_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.csharp_namespace + } + + fn mut_csharp_namespace_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.csharp_namespace + } + + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + + pub fn clear_uninterpreted_option(&mut self) { + self.uninterpreted_option.clear(); + } + + // Param is passed by value, moved + pub fn set_uninterpreted_option(&mut self, v: ::protobuf::RepeatedField) { + self.uninterpreted_option = v; + } + + // Mutable pointer to the field. + pub fn mut_uninterpreted_option(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } + + // Take field + pub fn take_uninterpreted_option(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.uninterpreted_option, ::protobuf::RepeatedField::new()) + } + + pub fn get_uninterpreted_option(&self) -> &[UninterpretedOption] { + &self.uninterpreted_option + } + + fn get_uninterpreted_option_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.uninterpreted_option + } + + fn mut_uninterpreted_option_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } +} + +impl ::protobuf::Message for FileOptions { + fn is_initialized(&self) -> bool { + for v in &self.uninterpreted_option { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.java_package)?; + }, + 8 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.java_outer_classname)?; + }, + 10 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.java_multiple_files = ::std::option::Option::Some(tmp); + }, + 20 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.java_generate_equals_and_hash = ::std::option::Option::Some(tmp); + }, + 27 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.java_string_check_utf8 = ::std::option::Option::Some(tmp); + }, + 9 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_enum()?; + self.optimize_for = ::std::option::Option::Some(tmp); + }, + 11 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.go_package)?; + }, + 16 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.cc_generic_services = ::std::option::Option::Some(tmp); + }, + 17 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.java_generic_services = ::std::option::Option::Some(tmp); + }, + 18 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.py_generic_services = ::std::option::Option::Some(tmp); + }, + 23 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.deprecated = ::std::option::Option::Some(tmp); + }, + 31 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.cc_enable_arenas = ::std::option::Option::Some(tmp); + }, + 36 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.objc_class_prefix)?; + }, + 37 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.csharp_namespace)?; + }, + 999 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.uninterpreted_option)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.java_package.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(ref v) = self.java_outer_classname.as_ref() { + my_size += ::protobuf::rt::string_size(8, &v); + } + if let Some(v) = self.java_multiple_files { + my_size += 2; + } + if let Some(v) = self.java_generate_equals_and_hash { + my_size += 3; + } + if let Some(v) = self.java_string_check_utf8 { + my_size += 3; + } + if let Some(v) = self.optimize_for { + my_size += ::protobuf::rt::enum_size(9, v); + } + if let Some(ref v) = self.go_package.as_ref() { + my_size += ::protobuf::rt::string_size(11, &v); + } + if let Some(v) = self.cc_generic_services { + my_size += 3; + } + if let Some(v) = self.java_generic_services { + my_size += 3; + } + if let Some(v) = self.py_generic_services { + my_size += 3; + } + if let Some(v) = self.deprecated { + my_size += 3; + } + if let Some(v) = self.cc_enable_arenas { + my_size += 3; + } + if let Some(ref v) = self.objc_class_prefix.as_ref() { + my_size += ::protobuf::rt::string_size(36, &v); + } + if let Some(ref v) = self.csharp_namespace.as_ref() { + my_size += ::protobuf::rt::string_size(37, &v); + } + for value in &self.uninterpreted_option { + let len = value.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.java_package.as_ref() { + os.write_string(1, &v)?; + } + if let Some(ref v) = self.java_outer_classname.as_ref() { + os.write_string(8, &v)?; + } + if let Some(v) = self.java_multiple_files { + os.write_bool(10, v)?; + } + if let Some(v) = self.java_generate_equals_and_hash { + os.write_bool(20, v)?; + } + if let Some(v) = self.java_string_check_utf8 { + os.write_bool(27, v)?; + } + if let Some(v) = self.optimize_for { + os.write_enum(9, v.value())?; + } + if let Some(ref v) = self.go_package.as_ref() { + os.write_string(11, &v)?; + } + if let Some(v) = self.cc_generic_services { + os.write_bool(16, v)?; + } + if let Some(v) = self.java_generic_services { + os.write_bool(17, v)?; + } + if let Some(v) = self.py_generic_services { + os.write_bool(18, v)?; + } + if let Some(v) = self.deprecated { + os.write_bool(23, v)?; + } + if let Some(v) = self.cc_enable_arenas { + os.write_bool(31, v)?; + } + if let Some(ref v) = self.objc_class_prefix.as_ref() { + os.write_string(36, &v)?; + } + if let Some(ref v) = self.csharp_namespace.as_ref() { + os.write_string(37, &v)?; + } + for v in &self.uninterpreted_option { + os.write_tag(999, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for FileOptions { + fn new() -> FileOptions { + FileOptions::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "java_package", + FileOptions::get_java_package_for_reflect, + FileOptions::mut_java_package_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "java_outer_classname", + FileOptions::get_java_outer_classname_for_reflect, + FileOptions::mut_java_outer_classname_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "java_multiple_files", + FileOptions::get_java_multiple_files_for_reflect, + FileOptions::mut_java_multiple_files_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "java_generate_equals_and_hash", + FileOptions::get_java_generate_equals_and_hash_for_reflect, + FileOptions::mut_java_generate_equals_and_hash_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "java_string_check_utf8", + FileOptions::get_java_string_check_utf8_for_reflect, + FileOptions::mut_java_string_check_utf8_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( + "optimize_for", + FileOptions::get_optimize_for_for_reflect, + FileOptions::mut_optimize_for_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "go_package", + FileOptions::get_go_package_for_reflect, + FileOptions::mut_go_package_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "cc_generic_services", + FileOptions::get_cc_generic_services_for_reflect, + FileOptions::mut_cc_generic_services_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "java_generic_services", + FileOptions::get_java_generic_services_for_reflect, + FileOptions::mut_java_generic_services_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "py_generic_services", + FileOptions::get_py_generic_services_for_reflect, + FileOptions::mut_py_generic_services_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "deprecated", + FileOptions::get_deprecated_for_reflect, + FileOptions::mut_deprecated_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "cc_enable_arenas", + FileOptions::get_cc_enable_arenas_for_reflect, + FileOptions::mut_cc_enable_arenas_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "objc_class_prefix", + FileOptions::get_objc_class_prefix_for_reflect, + FileOptions::mut_objc_class_prefix_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "csharp_namespace", + FileOptions::get_csharp_namespace_for_reflect, + FileOptions::mut_csharp_namespace_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "uninterpreted_option", + FileOptions::get_uninterpreted_option_for_reflect, + FileOptions::mut_uninterpreted_option_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "FileOptions", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for FileOptions { + fn clear(&mut self) { + self.clear_java_package(); + self.clear_java_outer_classname(); + self.clear_java_multiple_files(); + self.clear_java_generate_equals_and_hash(); + self.clear_java_string_check_utf8(); + self.clear_optimize_for(); + self.clear_go_package(); + self.clear_cc_generic_services(); + self.clear_java_generic_services(); + self.clear_py_generic_services(); + self.clear_deprecated(); + self.clear_cc_enable_arenas(); + self.clear_objc_class_prefix(); + self.clear_csharp_namespace(); + self.clear_uninterpreted_option(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for FileOptions { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for FileOptions { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum FileOptions_OptimizeMode { + SPEED = 1, + CODE_SIZE = 2, + LITE_RUNTIME = 3, +} + +impl ::protobuf::ProtobufEnum for FileOptions_OptimizeMode { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 1 => ::std::option::Option::Some(FileOptions_OptimizeMode::SPEED), + 2 => ::std::option::Option::Some(FileOptions_OptimizeMode::CODE_SIZE), + 3 => ::std::option::Option::Some(FileOptions_OptimizeMode::LITE_RUNTIME), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [FileOptions_OptimizeMode] = &[ + FileOptions_OptimizeMode::SPEED, + FileOptions_OptimizeMode::CODE_SIZE, + FileOptions_OptimizeMode::LITE_RUNTIME, + ]; + values + } + + fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, + }; + unsafe { + descriptor.get(|| { + ::protobuf::reflect::EnumDescriptor::new("FileOptions_OptimizeMode", file_descriptor_proto()) + }) + } + } +} + +impl ::std::marker::Copy for FileOptions_OptimizeMode { +} + +impl ::protobuf::reflect::ProtobufValue for FileOptions_OptimizeMode { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct MessageOptions { + // message fields + message_set_wire_format: ::std::option::Option, + no_standard_descriptor_accessor: ::std::option::Option, + deprecated: ::std::option::Option, + map_entry: ::std::option::Option, + uninterpreted_option: ::protobuf::RepeatedField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for MessageOptions {} + +impl MessageOptions { + pub fn new() -> MessageOptions { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static MessageOptions { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const MessageOptions, + }; + unsafe { + instance.get(MessageOptions::new) + } + } + + // optional bool message_set_wire_format = 1; + + pub fn clear_message_set_wire_format(&mut self) { + self.message_set_wire_format = ::std::option::Option::None; + } + + pub fn has_message_set_wire_format(&self) -> bool { + self.message_set_wire_format.is_some() + } + + // Param is passed by value, moved + pub fn set_message_set_wire_format(&mut self, v: bool) { + self.message_set_wire_format = ::std::option::Option::Some(v); + } + + pub fn get_message_set_wire_format(&self) -> bool { + self.message_set_wire_format.unwrap_or(false) + } + + fn get_message_set_wire_format_for_reflect(&self) -> &::std::option::Option { + &self.message_set_wire_format + } + + fn mut_message_set_wire_format_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.message_set_wire_format + } + + // optional bool no_standard_descriptor_accessor = 2; + + pub fn clear_no_standard_descriptor_accessor(&mut self) { + self.no_standard_descriptor_accessor = ::std::option::Option::None; + } + + pub fn has_no_standard_descriptor_accessor(&self) -> bool { + self.no_standard_descriptor_accessor.is_some() + } + + // Param is passed by value, moved + pub fn set_no_standard_descriptor_accessor(&mut self, v: bool) { + self.no_standard_descriptor_accessor = ::std::option::Option::Some(v); + } + + pub fn get_no_standard_descriptor_accessor(&self) -> bool { + self.no_standard_descriptor_accessor.unwrap_or(false) + } + + fn get_no_standard_descriptor_accessor_for_reflect(&self) -> &::std::option::Option { + &self.no_standard_descriptor_accessor + } + + fn mut_no_standard_descriptor_accessor_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.no_standard_descriptor_accessor + } + + // optional bool deprecated = 3; + + pub fn clear_deprecated(&mut self) { + self.deprecated = ::std::option::Option::None; + } + + pub fn has_deprecated(&self) -> bool { + self.deprecated.is_some() + } + + // Param is passed by value, moved + pub fn set_deprecated(&mut self, v: bool) { + self.deprecated = ::std::option::Option::Some(v); + } + + pub fn get_deprecated(&self) -> bool { + self.deprecated.unwrap_or(false) + } + + fn get_deprecated_for_reflect(&self) -> &::std::option::Option { + &self.deprecated + } + + fn mut_deprecated_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.deprecated + } + + // optional bool map_entry = 7; + + pub fn clear_map_entry(&mut self) { + self.map_entry = ::std::option::Option::None; + } + + pub fn has_map_entry(&self) -> bool { + self.map_entry.is_some() + } + + // Param is passed by value, moved + pub fn set_map_entry(&mut self, v: bool) { + self.map_entry = ::std::option::Option::Some(v); + } + + pub fn get_map_entry(&self) -> bool { + self.map_entry.unwrap_or(false) + } + + fn get_map_entry_for_reflect(&self) -> &::std::option::Option { + &self.map_entry + } + + fn mut_map_entry_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.map_entry + } + + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + + pub fn clear_uninterpreted_option(&mut self) { + self.uninterpreted_option.clear(); + } + + // Param is passed by value, moved + pub fn set_uninterpreted_option(&mut self, v: ::protobuf::RepeatedField) { + self.uninterpreted_option = v; + } + + // Mutable pointer to the field. + pub fn mut_uninterpreted_option(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } + + // Take field + pub fn take_uninterpreted_option(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.uninterpreted_option, ::protobuf::RepeatedField::new()) + } + + pub fn get_uninterpreted_option(&self) -> &[UninterpretedOption] { + &self.uninterpreted_option + } + + fn get_uninterpreted_option_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.uninterpreted_option + } + + fn mut_uninterpreted_option_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } +} + +impl ::protobuf::Message for MessageOptions { + fn is_initialized(&self) -> bool { + for v in &self.uninterpreted_option { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.message_set_wire_format = ::std::option::Option::Some(tmp); + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.no_standard_descriptor_accessor = ::std::option::Option::Some(tmp); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.deprecated = ::std::option::Option::Some(tmp); + }, + 7 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.map_entry = ::std::option::Option::Some(tmp); + }, + 999 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.uninterpreted_option)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(v) = self.message_set_wire_format { + my_size += 2; + } + if let Some(v) = self.no_standard_descriptor_accessor { + my_size += 2; + } + if let Some(v) = self.deprecated { + my_size += 2; + } + if let Some(v) = self.map_entry { + my_size += 2; + } + for value in &self.uninterpreted_option { + let len = value.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(v) = self.message_set_wire_format { + os.write_bool(1, v)?; + } + if let Some(v) = self.no_standard_descriptor_accessor { + os.write_bool(2, v)?; + } + if let Some(v) = self.deprecated { + os.write_bool(3, v)?; + } + if let Some(v) = self.map_entry { + os.write_bool(7, v)?; + } + for v in &self.uninterpreted_option { + os.write_tag(999, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for MessageOptions { + fn new() -> MessageOptions { + MessageOptions::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "message_set_wire_format", + MessageOptions::get_message_set_wire_format_for_reflect, + MessageOptions::mut_message_set_wire_format_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "no_standard_descriptor_accessor", + MessageOptions::get_no_standard_descriptor_accessor_for_reflect, + MessageOptions::mut_no_standard_descriptor_accessor_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "deprecated", + MessageOptions::get_deprecated_for_reflect, + MessageOptions::mut_deprecated_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "map_entry", + MessageOptions::get_map_entry_for_reflect, + MessageOptions::mut_map_entry_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "uninterpreted_option", + MessageOptions::get_uninterpreted_option_for_reflect, + MessageOptions::mut_uninterpreted_option_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "MessageOptions", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for MessageOptions { + fn clear(&mut self) { + self.clear_message_set_wire_format(); + self.clear_no_standard_descriptor_accessor(); + self.clear_deprecated(); + self.clear_map_entry(); + self.clear_uninterpreted_option(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for MessageOptions { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MessageOptions { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct FieldOptions { + // message fields + ctype: ::std::option::Option, + packed: ::std::option::Option, + jstype: ::std::option::Option, + lazy: ::std::option::Option, + deprecated: ::std::option::Option, + weak: ::std::option::Option, + uninterpreted_option: ::protobuf::RepeatedField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for FieldOptions {} + +impl FieldOptions { + pub fn new() -> FieldOptions { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static FieldOptions { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const FieldOptions, + }; + unsafe { + instance.get(FieldOptions::new) + } + } + + // optional .google.protobuf.FieldOptions.CType ctype = 1; + + pub fn clear_ctype(&mut self) { + self.ctype = ::std::option::Option::None; + } + + pub fn has_ctype(&self) -> bool { + self.ctype.is_some() + } + + // Param is passed by value, moved + pub fn set_ctype(&mut self, v: FieldOptions_CType) { + self.ctype = ::std::option::Option::Some(v); + } + + pub fn get_ctype(&self) -> FieldOptions_CType { + self.ctype.unwrap_or(FieldOptions_CType::STRING) + } + + fn get_ctype_for_reflect(&self) -> &::std::option::Option { + &self.ctype + } + + fn mut_ctype_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.ctype + } + + // optional bool packed = 2; + + pub fn clear_packed(&mut self) { + self.packed = ::std::option::Option::None; + } + + pub fn has_packed(&self) -> bool { + self.packed.is_some() + } + + // Param is passed by value, moved + pub fn set_packed(&mut self, v: bool) { + self.packed = ::std::option::Option::Some(v); + } + + pub fn get_packed(&self) -> bool { + self.packed.unwrap_or(false) + } + + fn get_packed_for_reflect(&self) -> &::std::option::Option { + &self.packed + } + + fn mut_packed_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.packed + } + + // optional .google.protobuf.FieldOptions.JSType jstype = 6; + + pub fn clear_jstype(&mut self) { + self.jstype = ::std::option::Option::None; + } + + pub fn has_jstype(&self) -> bool { + self.jstype.is_some() + } + + // Param is passed by value, moved + pub fn set_jstype(&mut self, v: FieldOptions_JSType) { + self.jstype = ::std::option::Option::Some(v); + } + + pub fn get_jstype(&self) -> FieldOptions_JSType { + self.jstype.unwrap_or(FieldOptions_JSType::JS_NORMAL) + } + + fn get_jstype_for_reflect(&self) -> &::std::option::Option { + &self.jstype + } + + fn mut_jstype_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.jstype + } + + // optional bool lazy = 5; + + pub fn clear_lazy(&mut self) { + self.lazy = ::std::option::Option::None; + } + + pub fn has_lazy(&self) -> bool { + self.lazy.is_some() + } + + // Param is passed by value, moved + pub fn set_lazy(&mut self, v: bool) { + self.lazy = ::std::option::Option::Some(v); + } + + pub fn get_lazy(&self) -> bool { + self.lazy.unwrap_or(false) + } + + fn get_lazy_for_reflect(&self) -> &::std::option::Option { + &self.lazy + } + + fn mut_lazy_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.lazy + } + + // optional bool deprecated = 3; + + pub fn clear_deprecated(&mut self) { + self.deprecated = ::std::option::Option::None; + } + + pub fn has_deprecated(&self) -> bool { + self.deprecated.is_some() + } + + // Param is passed by value, moved + pub fn set_deprecated(&mut self, v: bool) { + self.deprecated = ::std::option::Option::Some(v); + } + + pub fn get_deprecated(&self) -> bool { + self.deprecated.unwrap_or(false) + } + + fn get_deprecated_for_reflect(&self) -> &::std::option::Option { + &self.deprecated + } + + fn mut_deprecated_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.deprecated + } + + // optional bool weak = 10; + + pub fn clear_weak(&mut self) { + self.weak = ::std::option::Option::None; + } + + pub fn has_weak(&self) -> bool { + self.weak.is_some() + } + + // Param is passed by value, moved + pub fn set_weak(&mut self, v: bool) { + self.weak = ::std::option::Option::Some(v); + } + + pub fn get_weak(&self) -> bool { + self.weak.unwrap_or(false) + } + + fn get_weak_for_reflect(&self) -> &::std::option::Option { + &self.weak + } + + fn mut_weak_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.weak + } + + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + + pub fn clear_uninterpreted_option(&mut self) { + self.uninterpreted_option.clear(); + } + + // Param is passed by value, moved + pub fn set_uninterpreted_option(&mut self, v: ::protobuf::RepeatedField) { + self.uninterpreted_option = v; + } + + // Mutable pointer to the field. + pub fn mut_uninterpreted_option(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } + + // Take field + pub fn take_uninterpreted_option(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.uninterpreted_option, ::protobuf::RepeatedField::new()) + } + + pub fn get_uninterpreted_option(&self) -> &[UninterpretedOption] { + &self.uninterpreted_option + } + + fn get_uninterpreted_option_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.uninterpreted_option + } + + fn mut_uninterpreted_option_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } +} + +impl ::protobuf::Message for FieldOptions { + fn is_initialized(&self) -> bool { + for v in &self.uninterpreted_option { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_enum()?; + self.ctype = ::std::option::Option::Some(tmp); + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.packed = ::std::option::Option::Some(tmp); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_enum()?; + self.jstype = ::std::option::Option::Some(tmp); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.lazy = ::std::option::Option::Some(tmp); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.deprecated = ::std::option::Option::Some(tmp); + }, + 10 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.weak = ::std::option::Option::Some(tmp); + }, + 999 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.uninterpreted_option)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(v) = self.ctype { + my_size += ::protobuf::rt::enum_size(1, v); + } + if let Some(v) = self.packed { + my_size += 2; + } + if let Some(v) = self.jstype { + my_size += ::protobuf::rt::enum_size(6, v); + } + if let Some(v) = self.lazy { + my_size += 2; + } + if let Some(v) = self.deprecated { + my_size += 2; + } + if let Some(v) = self.weak { + my_size += 2; + } + for value in &self.uninterpreted_option { + let len = value.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(v) = self.ctype { + os.write_enum(1, v.value())?; + } + if let Some(v) = self.packed { + os.write_bool(2, v)?; + } + if let Some(v) = self.jstype { + os.write_enum(6, v.value())?; + } + if let Some(v) = self.lazy { + os.write_bool(5, v)?; + } + if let Some(v) = self.deprecated { + os.write_bool(3, v)?; + } + if let Some(v) = self.weak { + os.write_bool(10, v)?; + } + for v in &self.uninterpreted_option { + os.write_tag(999, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for FieldOptions { + fn new() -> FieldOptions { + FieldOptions::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( + "ctype", + FieldOptions::get_ctype_for_reflect, + FieldOptions::mut_ctype_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "packed", + FieldOptions::get_packed_for_reflect, + FieldOptions::mut_packed_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( + "jstype", + FieldOptions::get_jstype_for_reflect, + FieldOptions::mut_jstype_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "lazy", + FieldOptions::get_lazy_for_reflect, + FieldOptions::mut_lazy_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "deprecated", + FieldOptions::get_deprecated_for_reflect, + FieldOptions::mut_deprecated_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "weak", + FieldOptions::get_weak_for_reflect, + FieldOptions::mut_weak_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "uninterpreted_option", + FieldOptions::get_uninterpreted_option_for_reflect, + FieldOptions::mut_uninterpreted_option_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "FieldOptions", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for FieldOptions { + fn clear(&mut self) { + self.clear_ctype(); + self.clear_packed(); + self.clear_jstype(); + self.clear_lazy(); + self.clear_deprecated(); + self.clear_weak(); + self.clear_uninterpreted_option(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for FieldOptions { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for FieldOptions { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum FieldOptions_CType { + STRING = 0, + CORD = 1, + STRING_PIECE = 2, +} + +impl ::protobuf::ProtobufEnum for FieldOptions_CType { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(FieldOptions_CType::STRING), + 1 => ::std::option::Option::Some(FieldOptions_CType::CORD), + 2 => ::std::option::Option::Some(FieldOptions_CType::STRING_PIECE), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [FieldOptions_CType] = &[ + FieldOptions_CType::STRING, + FieldOptions_CType::CORD, + FieldOptions_CType::STRING_PIECE, + ]; + values + } + + fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, + }; + unsafe { + descriptor.get(|| { + ::protobuf::reflect::EnumDescriptor::new("FieldOptions_CType", file_descriptor_proto()) + }) + } + } +} + +impl ::std::marker::Copy for FieldOptions_CType { +} + +impl ::protobuf::reflect::ProtobufValue for FieldOptions_CType { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) + } +} + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum FieldOptions_JSType { + JS_NORMAL = 0, + JS_STRING = 1, + JS_NUMBER = 2, +} + +impl ::protobuf::ProtobufEnum for FieldOptions_JSType { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(FieldOptions_JSType::JS_NORMAL), + 1 => ::std::option::Option::Some(FieldOptions_JSType::JS_STRING), + 2 => ::std::option::Option::Some(FieldOptions_JSType::JS_NUMBER), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [FieldOptions_JSType] = &[ + FieldOptions_JSType::JS_NORMAL, + FieldOptions_JSType::JS_STRING, + FieldOptions_JSType::JS_NUMBER, + ]; + values + } + + fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, + }; + unsafe { + descriptor.get(|| { + ::protobuf::reflect::EnumDescriptor::new("FieldOptions_JSType", file_descriptor_proto()) + }) + } + } +} + +impl ::std::marker::Copy for FieldOptions_JSType { +} + +impl ::protobuf::reflect::ProtobufValue for FieldOptions_JSType { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct OneofOptions { + // message fields + uninterpreted_option: ::protobuf::RepeatedField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for OneofOptions {} + +impl OneofOptions { + pub fn new() -> OneofOptions { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static OneofOptions { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const OneofOptions, + }; + unsafe { + instance.get(OneofOptions::new) + } + } + + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + + pub fn clear_uninterpreted_option(&mut self) { + self.uninterpreted_option.clear(); + } + + // Param is passed by value, moved + pub fn set_uninterpreted_option(&mut self, v: ::protobuf::RepeatedField) { + self.uninterpreted_option = v; + } + + // Mutable pointer to the field. + pub fn mut_uninterpreted_option(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } + + // Take field + pub fn take_uninterpreted_option(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.uninterpreted_option, ::protobuf::RepeatedField::new()) + } + + pub fn get_uninterpreted_option(&self) -> &[UninterpretedOption] { + &self.uninterpreted_option + } + + fn get_uninterpreted_option_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.uninterpreted_option + } + + fn mut_uninterpreted_option_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } +} + +impl ::protobuf::Message for OneofOptions { + fn is_initialized(&self) -> bool { + for v in &self.uninterpreted_option { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 999 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.uninterpreted_option)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + for value in &self.uninterpreted_option { + let len = value.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + for v in &self.uninterpreted_option { + os.write_tag(999, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for OneofOptions { + fn new() -> OneofOptions { + OneofOptions::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "uninterpreted_option", + OneofOptions::get_uninterpreted_option_for_reflect, + OneofOptions::mut_uninterpreted_option_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "OneofOptions", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for OneofOptions { + fn clear(&mut self) { + self.clear_uninterpreted_option(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for OneofOptions { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for OneofOptions { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct EnumOptions { + // message fields + allow_alias: ::std::option::Option, + deprecated: ::std::option::Option, + uninterpreted_option: ::protobuf::RepeatedField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for EnumOptions {} + +impl EnumOptions { + pub fn new() -> EnumOptions { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static EnumOptions { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const EnumOptions, + }; + unsafe { + instance.get(EnumOptions::new) + } + } + + // optional bool allow_alias = 2; + + pub fn clear_allow_alias(&mut self) { + self.allow_alias = ::std::option::Option::None; + } + + pub fn has_allow_alias(&self) -> bool { + self.allow_alias.is_some() + } + + // Param is passed by value, moved + pub fn set_allow_alias(&mut self, v: bool) { + self.allow_alias = ::std::option::Option::Some(v); + } + + pub fn get_allow_alias(&self) -> bool { + self.allow_alias.unwrap_or(false) + } + + fn get_allow_alias_for_reflect(&self) -> &::std::option::Option { + &self.allow_alias + } + + fn mut_allow_alias_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.allow_alias + } + + // optional bool deprecated = 3; + + pub fn clear_deprecated(&mut self) { + self.deprecated = ::std::option::Option::None; + } + + pub fn has_deprecated(&self) -> bool { + self.deprecated.is_some() + } + + // Param is passed by value, moved + pub fn set_deprecated(&mut self, v: bool) { + self.deprecated = ::std::option::Option::Some(v); + } + + pub fn get_deprecated(&self) -> bool { + self.deprecated.unwrap_or(false) + } + + fn get_deprecated_for_reflect(&self) -> &::std::option::Option { + &self.deprecated + } + + fn mut_deprecated_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.deprecated + } + + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + + pub fn clear_uninterpreted_option(&mut self) { + self.uninterpreted_option.clear(); + } + + // Param is passed by value, moved + pub fn set_uninterpreted_option(&mut self, v: ::protobuf::RepeatedField) { + self.uninterpreted_option = v; + } + + // Mutable pointer to the field. + pub fn mut_uninterpreted_option(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } + + // Take field + pub fn take_uninterpreted_option(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.uninterpreted_option, ::protobuf::RepeatedField::new()) + } + + pub fn get_uninterpreted_option(&self) -> &[UninterpretedOption] { + &self.uninterpreted_option + } + + fn get_uninterpreted_option_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.uninterpreted_option + } + + fn mut_uninterpreted_option_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } +} + +impl ::protobuf::Message for EnumOptions { + fn is_initialized(&self) -> bool { + for v in &self.uninterpreted_option { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.allow_alias = ::std::option::Option::Some(tmp); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.deprecated = ::std::option::Option::Some(tmp); + }, + 999 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.uninterpreted_option)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(v) = self.allow_alias { + my_size += 2; + } + if let Some(v) = self.deprecated { + my_size += 2; + } + for value in &self.uninterpreted_option { + let len = value.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(v) = self.allow_alias { + os.write_bool(2, v)?; + } + if let Some(v) = self.deprecated { + os.write_bool(3, v)?; + } + for v in &self.uninterpreted_option { + os.write_tag(999, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for EnumOptions { + fn new() -> EnumOptions { + EnumOptions::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "allow_alias", + EnumOptions::get_allow_alias_for_reflect, + EnumOptions::mut_allow_alias_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "deprecated", + EnumOptions::get_deprecated_for_reflect, + EnumOptions::mut_deprecated_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "uninterpreted_option", + EnumOptions::get_uninterpreted_option_for_reflect, + EnumOptions::mut_uninterpreted_option_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "EnumOptions", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for EnumOptions { + fn clear(&mut self) { + self.clear_allow_alias(); + self.clear_deprecated(); + self.clear_uninterpreted_option(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for EnumOptions { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for EnumOptions { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct EnumValueOptions { + // message fields + deprecated: ::std::option::Option, + uninterpreted_option: ::protobuf::RepeatedField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for EnumValueOptions {} + +impl EnumValueOptions { + pub fn new() -> EnumValueOptions { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static EnumValueOptions { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const EnumValueOptions, + }; + unsafe { + instance.get(EnumValueOptions::new) + } + } + + // optional bool deprecated = 1; + + pub fn clear_deprecated(&mut self) { + self.deprecated = ::std::option::Option::None; + } + + pub fn has_deprecated(&self) -> bool { + self.deprecated.is_some() + } + + // Param is passed by value, moved + pub fn set_deprecated(&mut self, v: bool) { + self.deprecated = ::std::option::Option::Some(v); + } + + pub fn get_deprecated(&self) -> bool { + self.deprecated.unwrap_or(false) + } + + fn get_deprecated_for_reflect(&self) -> &::std::option::Option { + &self.deprecated + } + + fn mut_deprecated_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.deprecated + } + + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + + pub fn clear_uninterpreted_option(&mut self) { + self.uninterpreted_option.clear(); + } + + // Param is passed by value, moved + pub fn set_uninterpreted_option(&mut self, v: ::protobuf::RepeatedField) { + self.uninterpreted_option = v; + } + + // Mutable pointer to the field. + pub fn mut_uninterpreted_option(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } + + // Take field + pub fn take_uninterpreted_option(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.uninterpreted_option, ::protobuf::RepeatedField::new()) + } + + pub fn get_uninterpreted_option(&self) -> &[UninterpretedOption] { + &self.uninterpreted_option + } + + fn get_uninterpreted_option_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.uninterpreted_option + } + + fn mut_uninterpreted_option_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } +} + +impl ::protobuf::Message for EnumValueOptions { + fn is_initialized(&self) -> bool { + for v in &self.uninterpreted_option { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.deprecated = ::std::option::Option::Some(tmp); + }, + 999 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.uninterpreted_option)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(v) = self.deprecated { + my_size += 2; + } + for value in &self.uninterpreted_option { + let len = value.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(v) = self.deprecated { + os.write_bool(1, v)?; + } + for v in &self.uninterpreted_option { + os.write_tag(999, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for EnumValueOptions { + fn new() -> EnumValueOptions { + EnumValueOptions::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "deprecated", + EnumValueOptions::get_deprecated_for_reflect, + EnumValueOptions::mut_deprecated_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "uninterpreted_option", + EnumValueOptions::get_uninterpreted_option_for_reflect, + EnumValueOptions::mut_uninterpreted_option_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "EnumValueOptions", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for EnumValueOptions { + fn clear(&mut self) { + self.clear_deprecated(); + self.clear_uninterpreted_option(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for EnumValueOptions { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for EnumValueOptions { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct ServiceOptions { + // message fields + deprecated: ::std::option::Option, + uninterpreted_option: ::protobuf::RepeatedField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for ServiceOptions {} + +impl ServiceOptions { + pub fn new() -> ServiceOptions { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static ServiceOptions { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ServiceOptions, + }; + unsafe { + instance.get(ServiceOptions::new) + } + } + + // optional bool deprecated = 33; + + pub fn clear_deprecated(&mut self) { + self.deprecated = ::std::option::Option::None; + } + + pub fn has_deprecated(&self) -> bool { + self.deprecated.is_some() + } + + // Param is passed by value, moved + pub fn set_deprecated(&mut self, v: bool) { + self.deprecated = ::std::option::Option::Some(v); + } + + pub fn get_deprecated(&self) -> bool { + self.deprecated.unwrap_or(false) + } + + fn get_deprecated_for_reflect(&self) -> &::std::option::Option { + &self.deprecated + } + + fn mut_deprecated_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.deprecated + } + + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + + pub fn clear_uninterpreted_option(&mut self) { + self.uninterpreted_option.clear(); + } + + // Param is passed by value, moved + pub fn set_uninterpreted_option(&mut self, v: ::protobuf::RepeatedField) { + self.uninterpreted_option = v; + } + + // Mutable pointer to the field. + pub fn mut_uninterpreted_option(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } + + // Take field + pub fn take_uninterpreted_option(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.uninterpreted_option, ::protobuf::RepeatedField::new()) + } + + pub fn get_uninterpreted_option(&self) -> &[UninterpretedOption] { + &self.uninterpreted_option + } + + fn get_uninterpreted_option_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.uninterpreted_option + } + + fn mut_uninterpreted_option_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } +} + +impl ::protobuf::Message for ServiceOptions { + fn is_initialized(&self) -> bool { + for v in &self.uninterpreted_option { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 33 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.deprecated = ::std::option::Option::Some(tmp); + }, + 999 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.uninterpreted_option)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(v) = self.deprecated { + my_size += 3; + } + for value in &self.uninterpreted_option { + let len = value.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(v) = self.deprecated { + os.write_bool(33, v)?; + } + for v in &self.uninterpreted_option { + os.write_tag(999, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for ServiceOptions { + fn new() -> ServiceOptions { + ServiceOptions::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "deprecated", + ServiceOptions::get_deprecated_for_reflect, + ServiceOptions::mut_deprecated_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "uninterpreted_option", + ServiceOptions::get_uninterpreted_option_for_reflect, + ServiceOptions::mut_uninterpreted_option_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "ServiceOptions", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for ServiceOptions { + fn clear(&mut self) { + self.clear_deprecated(); + self.clear_uninterpreted_option(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for ServiceOptions { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for ServiceOptions { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct MethodOptions { + // message fields + deprecated: ::std::option::Option, + uninterpreted_option: ::protobuf::RepeatedField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for MethodOptions {} + +impl MethodOptions { + pub fn new() -> MethodOptions { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static MethodOptions { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const MethodOptions, + }; + unsafe { + instance.get(MethodOptions::new) + } + } + + // optional bool deprecated = 33; + + pub fn clear_deprecated(&mut self) { + self.deprecated = ::std::option::Option::None; + } + + pub fn has_deprecated(&self) -> bool { + self.deprecated.is_some() + } + + // Param is passed by value, moved + pub fn set_deprecated(&mut self, v: bool) { + self.deprecated = ::std::option::Option::Some(v); + } + + pub fn get_deprecated(&self) -> bool { + self.deprecated.unwrap_or(false) + } + + fn get_deprecated_for_reflect(&self) -> &::std::option::Option { + &self.deprecated + } + + fn mut_deprecated_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.deprecated + } + + // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999; + + pub fn clear_uninterpreted_option(&mut self) { + self.uninterpreted_option.clear(); + } + + // Param is passed by value, moved + pub fn set_uninterpreted_option(&mut self, v: ::protobuf::RepeatedField) { + self.uninterpreted_option = v; + } + + // Mutable pointer to the field. + pub fn mut_uninterpreted_option(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } + + // Take field + pub fn take_uninterpreted_option(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.uninterpreted_option, ::protobuf::RepeatedField::new()) + } + + pub fn get_uninterpreted_option(&self) -> &[UninterpretedOption] { + &self.uninterpreted_option + } + + fn get_uninterpreted_option_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.uninterpreted_option + } + + fn mut_uninterpreted_option_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.uninterpreted_option + } +} + +impl ::protobuf::Message for MethodOptions { + fn is_initialized(&self) -> bool { + for v in &self.uninterpreted_option { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 33 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.deprecated = ::std::option::Option::Some(tmp); + }, + 999 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.uninterpreted_option)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(v) = self.deprecated { + my_size += 3; + } + for value in &self.uninterpreted_option { + let len = value.compute_size(); + my_size += 2 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(v) = self.deprecated { + os.write_bool(33, v)?; + } + for v in &self.uninterpreted_option { + os.write_tag(999, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for MethodOptions { + fn new() -> MethodOptions { + MethodOptions::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "deprecated", + MethodOptions::get_deprecated_for_reflect, + MethodOptions::mut_deprecated_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "uninterpreted_option", + MethodOptions::get_uninterpreted_option_for_reflect, + MethodOptions::mut_uninterpreted_option_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "MethodOptions", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for MethodOptions { + fn clear(&mut self) { + self.clear_deprecated(); + self.clear_uninterpreted_option(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for MethodOptions { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for MethodOptions { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct UninterpretedOption { + // message fields + name: ::protobuf::RepeatedField, + identifier_value: ::protobuf::SingularField<::std::string::String>, + positive_int_value: ::std::option::Option, + negative_int_value: ::std::option::Option, + double_value: ::std::option::Option, + string_value: ::protobuf::SingularField<::std::vec::Vec>, + aggregate_value: ::protobuf::SingularField<::std::string::String>, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for UninterpretedOption {} + +impl UninterpretedOption { + pub fn new() -> UninterpretedOption { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static UninterpretedOption { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const UninterpretedOption, + }; + unsafe { + instance.get(UninterpretedOption::new) + } + } + + // repeated .google.protobuf.UninterpretedOption.NamePart name = 2; + + pub fn clear_name(&mut self) { + self.name.clear(); + } + + // Param is passed by value, moved + pub fn set_name(&mut self, v: ::protobuf::RepeatedField) { + self.name = v; + } + + // Mutable pointer to the field. + pub fn mut_name(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.name + } + + // Take field + pub fn take_name(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.name, ::protobuf::RepeatedField::new()) + } + + pub fn get_name(&self) -> &[UninterpretedOption_NamePart] { + &self.name + } + + fn get_name_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.name + } + + fn mut_name_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.name + } + + // optional string identifier_value = 3; + + pub fn clear_identifier_value(&mut self) { + self.identifier_value.clear(); + } + + pub fn has_identifier_value(&self) -> bool { + self.identifier_value.is_some() + } + + // Param is passed by value, moved + pub fn set_identifier_value(&mut self, v: ::std::string::String) { + self.identifier_value = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_identifier_value(&mut self) -> &mut ::std::string::String { + if self.identifier_value.is_none() { + self.identifier_value.set_default(); + } + self.identifier_value.as_mut().unwrap() + } + + // Take field + pub fn take_identifier_value(&mut self) -> ::std::string::String { + self.identifier_value.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_identifier_value(&self) -> &str { + match self.identifier_value.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_identifier_value_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.identifier_value + } + + fn mut_identifier_value_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.identifier_value + } + + // optional uint64 positive_int_value = 4; + + pub fn clear_positive_int_value(&mut self) { + self.positive_int_value = ::std::option::Option::None; + } + + pub fn has_positive_int_value(&self) -> bool { + self.positive_int_value.is_some() + } + + // Param is passed by value, moved + pub fn set_positive_int_value(&mut self, v: u64) { + self.positive_int_value = ::std::option::Option::Some(v); + } + + pub fn get_positive_int_value(&self) -> u64 { + self.positive_int_value.unwrap_or(0) + } + + fn get_positive_int_value_for_reflect(&self) -> &::std::option::Option { + &self.positive_int_value + } + + fn mut_positive_int_value_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.positive_int_value + } + + // optional int64 negative_int_value = 5; + + pub fn clear_negative_int_value(&mut self) { + self.negative_int_value = ::std::option::Option::None; + } + + pub fn has_negative_int_value(&self) -> bool { + self.negative_int_value.is_some() + } + + // Param is passed by value, moved + pub fn set_negative_int_value(&mut self, v: i64) { + self.negative_int_value = ::std::option::Option::Some(v); + } + + pub fn get_negative_int_value(&self) -> i64 { + self.negative_int_value.unwrap_or(0) + } + + fn get_negative_int_value_for_reflect(&self) -> &::std::option::Option { + &self.negative_int_value + } + + fn mut_negative_int_value_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.negative_int_value + } + + // optional double double_value = 6; + + pub fn clear_double_value(&mut self) { + self.double_value = ::std::option::Option::None; + } + + pub fn has_double_value(&self) -> bool { + self.double_value.is_some() + } + + // Param is passed by value, moved + pub fn set_double_value(&mut self, v: f64) { + self.double_value = ::std::option::Option::Some(v); + } + + pub fn get_double_value(&self) -> f64 { + self.double_value.unwrap_or(0.) + } + + fn get_double_value_for_reflect(&self) -> &::std::option::Option { + &self.double_value + } + + fn mut_double_value_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.double_value + } + + // optional bytes string_value = 7; + + pub fn clear_string_value(&mut self) { + self.string_value.clear(); + } + + pub fn has_string_value(&self) -> bool { + self.string_value.is_some() + } + + // Param is passed by value, moved + pub fn set_string_value(&mut self, v: ::std::vec::Vec) { + self.string_value = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_string_value(&mut self) -> &mut ::std::vec::Vec { + if self.string_value.is_none() { + self.string_value.set_default(); + } + self.string_value.as_mut().unwrap() + } + + // Take field + pub fn take_string_value(&mut self) -> ::std::vec::Vec { + self.string_value.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + pub fn get_string_value(&self) -> &[u8] { + match self.string_value.as_ref() { + Some(v) => &v, + None => &[], + } + } + + fn get_string_value_for_reflect(&self) -> &::protobuf::SingularField<::std::vec::Vec> { + &self.string_value + } + + fn mut_string_value_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::vec::Vec> { + &mut self.string_value + } + + // optional string aggregate_value = 8; + + pub fn clear_aggregate_value(&mut self) { + self.aggregate_value.clear(); + } + + pub fn has_aggregate_value(&self) -> bool { + self.aggregate_value.is_some() + } + + // Param is passed by value, moved + pub fn set_aggregate_value(&mut self, v: ::std::string::String) { + self.aggregate_value = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_aggregate_value(&mut self) -> &mut ::std::string::String { + if self.aggregate_value.is_none() { + self.aggregate_value.set_default(); + } + self.aggregate_value.as_mut().unwrap() + } + + // Take field + pub fn take_aggregate_value(&mut self) -> ::std::string::String { + self.aggregate_value.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_aggregate_value(&self) -> &str { + match self.aggregate_value.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_aggregate_value_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.aggregate_value + } + + fn mut_aggregate_value_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.aggregate_value + } +} + +impl ::protobuf::Message for UninterpretedOption { + fn is_initialized(&self) -> bool { + for v in &self.name { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 2 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.name)?; + }, + 3 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.identifier_value)?; + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_uint64()?; + self.positive_int_value = ::std::option::Option::Some(tmp); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int64()?; + self.negative_int_value = ::std::option::Option::Some(tmp); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeFixed64 { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_double()?; + self.double_value = ::std::option::Option::Some(tmp); + }, + 7 => { + ::protobuf::rt::read_singular_bytes_into(wire_type, is, &mut self.string_value)?; + }, + 8 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.aggregate_value)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + for value in &self.name { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + if let Some(ref v) = self.identifier_value.as_ref() { + my_size += ::protobuf::rt::string_size(3, &v); + } + if let Some(v) = self.positive_int_value { + my_size += ::protobuf::rt::value_size(4, v, ::protobuf::wire_format::WireTypeVarint); + } + if let Some(v) = self.negative_int_value { + my_size += ::protobuf::rt::value_size(5, v, ::protobuf::wire_format::WireTypeVarint); + } + if let Some(v) = self.double_value { + my_size += 9; + } + if let Some(ref v) = self.string_value.as_ref() { + my_size += ::protobuf::rt::bytes_size(7, &v); + } + if let Some(ref v) = self.aggregate_value.as_ref() { + my_size += ::protobuf::rt::string_size(8, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + for v in &self.name { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + if let Some(ref v) = self.identifier_value.as_ref() { + os.write_string(3, &v)?; + } + if let Some(v) = self.positive_int_value { + os.write_uint64(4, v)?; + } + if let Some(v) = self.negative_int_value { + os.write_int64(5, v)?; + } + if let Some(v) = self.double_value { + os.write_double(6, v)?; + } + if let Some(ref v) = self.string_value.as_ref() { + os.write_bytes(7, &v)?; + } + if let Some(ref v) = self.aggregate_value.as_ref() { + os.write_string(8, &v)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for UninterpretedOption { + fn new() -> UninterpretedOption { + UninterpretedOption::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "name", + UninterpretedOption::get_name_for_reflect, + UninterpretedOption::mut_name_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "identifier_value", + UninterpretedOption::get_identifier_value_for_reflect, + UninterpretedOption::mut_identifier_value_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( + "positive_int_value", + UninterpretedOption::get_positive_int_value_for_reflect, + UninterpretedOption::mut_positive_int_value_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( + "negative_int_value", + UninterpretedOption::get_negative_int_value_for_reflect, + UninterpretedOption::mut_negative_int_value_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeDouble>( + "double_value", + UninterpretedOption::get_double_value_for_reflect, + UninterpretedOption::mut_double_value_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>( + "string_value", + UninterpretedOption::get_string_value_for_reflect, + UninterpretedOption::mut_string_value_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "aggregate_value", + UninterpretedOption::get_aggregate_value_for_reflect, + UninterpretedOption::mut_aggregate_value_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "UninterpretedOption", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for UninterpretedOption { + fn clear(&mut self) { + self.clear_name(); + self.clear_identifier_value(); + self.clear_positive_int_value(); + self.clear_negative_int_value(); + self.clear_double_value(); + self.clear_string_value(); + self.clear_aggregate_value(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for UninterpretedOption { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for UninterpretedOption { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct UninterpretedOption_NamePart { + // message fields + name_part: ::protobuf::SingularField<::std::string::String>, + is_extension: ::std::option::Option, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for UninterpretedOption_NamePart {} + +impl UninterpretedOption_NamePart { + pub fn new() -> UninterpretedOption_NamePart { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static UninterpretedOption_NamePart { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const UninterpretedOption_NamePart, + }; + unsafe { + instance.get(UninterpretedOption_NamePart::new) + } + } + + // required string name_part = 1; + + pub fn clear_name_part(&mut self) { + self.name_part.clear(); + } + + pub fn has_name_part(&self) -> bool { + self.name_part.is_some() + } + + // Param is passed by value, moved + pub fn set_name_part(&mut self, v: ::std::string::String) { + self.name_part = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_name_part(&mut self) -> &mut ::std::string::String { + if self.name_part.is_none() { + self.name_part.set_default(); + } + self.name_part.as_mut().unwrap() + } + + // Take field + pub fn take_name_part(&mut self) -> ::std::string::String { + self.name_part.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_name_part(&self) -> &str { + match self.name_part.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_name_part_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.name_part + } + + fn mut_name_part_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.name_part + } + + // required bool is_extension = 2; + + pub fn clear_is_extension(&mut self) { + self.is_extension = ::std::option::Option::None; + } + + pub fn has_is_extension(&self) -> bool { + self.is_extension.is_some() + } + + // Param is passed by value, moved + pub fn set_is_extension(&mut self, v: bool) { + self.is_extension = ::std::option::Option::Some(v); + } + + pub fn get_is_extension(&self) -> bool { + self.is_extension.unwrap_or(false) + } + + fn get_is_extension_for_reflect(&self) -> &::std::option::Option { + &self.is_extension + } + + fn mut_is_extension_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.is_extension + } +} + +impl ::protobuf::Message for UninterpretedOption_NamePart { + fn is_initialized(&self) -> bool { + if self.name_part.is_none() { + return false; + } + if self.is_extension.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.name_part)?; + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.is_extension = ::std::option::Option::Some(tmp); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.name_part.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(v) = self.is_extension { + my_size += 2; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.name_part.as_ref() { + os.write_string(1, &v)?; + } + if let Some(v) = self.is_extension { + os.write_bool(2, v)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for UninterpretedOption_NamePart { + fn new() -> UninterpretedOption_NamePart { + UninterpretedOption_NamePart::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "name_part", + UninterpretedOption_NamePart::get_name_part_for_reflect, + UninterpretedOption_NamePart::mut_name_part_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "is_extension", + UninterpretedOption_NamePart::get_is_extension_for_reflect, + UninterpretedOption_NamePart::mut_is_extension_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "UninterpretedOption_NamePart", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for UninterpretedOption_NamePart { + fn clear(&mut self) { + self.clear_name_part(); + self.clear_is_extension(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for UninterpretedOption_NamePart { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for UninterpretedOption_NamePart { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct SourceCodeInfo { + // message fields + location: ::protobuf::RepeatedField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for SourceCodeInfo {} + +impl SourceCodeInfo { + pub fn new() -> SourceCodeInfo { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static SourceCodeInfo { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const SourceCodeInfo, + }; + unsafe { + instance.get(SourceCodeInfo::new) + } + } + + // repeated .google.protobuf.SourceCodeInfo.Location location = 1; + + pub fn clear_location(&mut self) { + self.location.clear(); + } + + // Param is passed by value, moved + pub fn set_location(&mut self, v: ::protobuf::RepeatedField) { + self.location = v; + } + + // Mutable pointer to the field. + pub fn mut_location(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.location + } + + // Take field + pub fn take_location(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.location, ::protobuf::RepeatedField::new()) + } + + pub fn get_location(&self) -> &[SourceCodeInfo_Location] { + &self.location + } + + fn get_location_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.location + } + + fn mut_location_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.location + } +} + +impl ::protobuf::Message for SourceCodeInfo { + fn is_initialized(&self) -> bool { + for v in &self.location { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.location)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + for value in &self.location { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + for v in &self.location { + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for SourceCodeInfo { + fn new() -> SourceCodeInfo { + SourceCodeInfo::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "location", + SourceCodeInfo::get_location_for_reflect, + SourceCodeInfo::mut_location_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "SourceCodeInfo", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for SourceCodeInfo { + fn clear(&mut self) { + self.clear_location(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for SourceCodeInfo { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for SourceCodeInfo { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct SourceCodeInfo_Location { + // message fields + path: ::std::vec::Vec, + span: ::std::vec::Vec, + leading_comments: ::protobuf::SingularField<::std::string::String>, + trailing_comments: ::protobuf::SingularField<::std::string::String>, + leading_detached_comments: ::protobuf::RepeatedField<::std::string::String>, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for SourceCodeInfo_Location {} + +impl SourceCodeInfo_Location { + pub fn new() -> SourceCodeInfo_Location { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static SourceCodeInfo_Location { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const SourceCodeInfo_Location, + }; + unsafe { + instance.get(SourceCodeInfo_Location::new) + } + } + + // repeated int32 path = 1; + + pub fn clear_path(&mut self) { + self.path.clear(); + } + + // Param is passed by value, moved + pub fn set_path(&mut self, v: ::std::vec::Vec) { + self.path = v; + } + + // Mutable pointer to the field. + pub fn mut_path(&mut self) -> &mut ::std::vec::Vec { + &mut self.path + } + + // Take field + pub fn take_path(&mut self) -> ::std::vec::Vec { + ::std::mem::replace(&mut self.path, ::std::vec::Vec::new()) + } + + pub fn get_path(&self) -> &[i32] { + &self.path + } + + fn get_path_for_reflect(&self) -> &::std::vec::Vec { + &self.path + } + + fn mut_path_for_reflect(&mut self) -> &mut ::std::vec::Vec { + &mut self.path + } + + // repeated int32 span = 2; + + pub fn clear_span(&mut self) { + self.span.clear(); + } + + // Param is passed by value, moved + pub fn set_span(&mut self, v: ::std::vec::Vec) { + self.span = v; + } + + // Mutable pointer to the field. + pub fn mut_span(&mut self) -> &mut ::std::vec::Vec { + &mut self.span + } + + // Take field + pub fn take_span(&mut self) -> ::std::vec::Vec { + ::std::mem::replace(&mut self.span, ::std::vec::Vec::new()) + } + + pub fn get_span(&self) -> &[i32] { + &self.span + } + + fn get_span_for_reflect(&self) -> &::std::vec::Vec { + &self.span + } + + fn mut_span_for_reflect(&mut self) -> &mut ::std::vec::Vec { + &mut self.span + } + + // optional string leading_comments = 3; + + pub fn clear_leading_comments(&mut self) { + self.leading_comments.clear(); + } + + pub fn has_leading_comments(&self) -> bool { + self.leading_comments.is_some() + } + + // Param is passed by value, moved + pub fn set_leading_comments(&mut self, v: ::std::string::String) { + self.leading_comments = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_leading_comments(&mut self) -> &mut ::std::string::String { + if self.leading_comments.is_none() { + self.leading_comments.set_default(); + } + self.leading_comments.as_mut().unwrap() + } + + // Take field + pub fn take_leading_comments(&mut self) -> ::std::string::String { + self.leading_comments.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_leading_comments(&self) -> &str { + match self.leading_comments.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_leading_comments_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.leading_comments + } + + fn mut_leading_comments_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.leading_comments + } + + // optional string trailing_comments = 4; + + pub fn clear_trailing_comments(&mut self) { + self.trailing_comments.clear(); + } + + pub fn has_trailing_comments(&self) -> bool { + self.trailing_comments.is_some() + } + + // Param is passed by value, moved + pub fn set_trailing_comments(&mut self, v: ::std::string::String) { + self.trailing_comments = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_trailing_comments(&mut self) -> &mut ::std::string::String { + if self.trailing_comments.is_none() { + self.trailing_comments.set_default(); + } + self.trailing_comments.as_mut().unwrap() + } + + // Take field + pub fn take_trailing_comments(&mut self) -> ::std::string::String { + self.trailing_comments.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_trailing_comments(&self) -> &str { + match self.trailing_comments.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_trailing_comments_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.trailing_comments + } + + fn mut_trailing_comments_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.trailing_comments + } + + // repeated string leading_detached_comments = 6; + + pub fn clear_leading_detached_comments(&mut self) { + self.leading_detached_comments.clear(); + } + + // Param is passed by value, moved + pub fn set_leading_detached_comments(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { + self.leading_detached_comments = v; + } + + // Mutable pointer to the field. + pub fn mut_leading_detached_comments(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.leading_detached_comments + } + + // Take field + pub fn take_leading_detached_comments(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { + ::std::mem::replace(&mut self.leading_detached_comments, ::protobuf::RepeatedField::new()) + } + + pub fn get_leading_detached_comments(&self) -> &[::std::string::String] { + &self.leading_detached_comments + } + + fn get_leading_detached_comments_for_reflect(&self) -> &::protobuf::RepeatedField<::std::string::String> { + &self.leading_detached_comments + } + + fn mut_leading_detached_comments_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.leading_detached_comments + } +} + +impl ::protobuf::Message for SourceCodeInfo_Location { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_repeated_int32_into(wire_type, is, &mut self.path)?; + }, + 2 => { + ::protobuf::rt::read_repeated_int32_into(wire_type, is, &mut self.span)?; + }, + 3 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.leading_comments)?; + }, + 4 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.trailing_comments)?; + }, + 6 => { + ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.leading_detached_comments)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.path.is_empty() { + my_size += ::protobuf::rt::vec_packed_varint_size(1, &self.path); + } + if !self.span.is_empty() { + my_size += ::protobuf::rt::vec_packed_varint_size(2, &self.span); + } + if let Some(ref v) = self.leading_comments.as_ref() { + my_size += ::protobuf::rt::string_size(3, &v); + } + if let Some(ref v) = self.trailing_comments.as_ref() { + my_size += ::protobuf::rt::string_size(4, &v); + } + for value in &self.leading_detached_comments { + my_size += ::protobuf::rt::string_size(6, &value); + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.path.is_empty() { + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; + // TODO: Data size is computed again, it should be cached + os.write_raw_varint32(::protobuf::rt::vec_packed_varint_data_size(&self.path))?; + for v in &self.path { + os.write_int32_no_tag(*v)?; + }; + } + if !self.span.is_empty() { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + // TODO: Data size is computed again, it should be cached + os.write_raw_varint32(::protobuf::rt::vec_packed_varint_data_size(&self.span))?; + for v in &self.span { + os.write_int32_no_tag(*v)?; + }; + } + if let Some(ref v) = self.leading_comments.as_ref() { + os.write_string(3, &v)?; + } + if let Some(ref v) = self.trailing_comments.as_ref() { + os.write_string(4, &v)?; + } + for v in &self.leading_detached_comments { + os.write_string(6, &v)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for SourceCodeInfo_Location { + fn new() -> SourceCodeInfo_Location { + SourceCodeInfo_Location::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_vec_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "path", + SourceCodeInfo_Location::get_path_for_reflect, + SourceCodeInfo_Location::mut_path_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_vec_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "span", + SourceCodeInfo_Location::get_span_for_reflect, + SourceCodeInfo_Location::mut_span_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "leading_comments", + SourceCodeInfo_Location::get_leading_comments_for_reflect, + SourceCodeInfo_Location::mut_leading_comments_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "trailing_comments", + SourceCodeInfo_Location::get_trailing_comments_for_reflect, + SourceCodeInfo_Location::mut_trailing_comments_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "leading_detached_comments", + SourceCodeInfo_Location::get_leading_detached_comments_for_reflect, + SourceCodeInfo_Location::mut_leading_detached_comments_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "SourceCodeInfo_Location", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for SourceCodeInfo_Location { + fn clear(&mut self) { + self.clear_path(); + self.clear_span(); + self.clear_leading_comments(); + self.clear_trailing_comments(); + self.clear_leading_detached_comments(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for SourceCodeInfo_Location { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for SourceCodeInfo_Location { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct GeneratedCodeInfo { + // message fields + annotation: ::protobuf::RepeatedField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for GeneratedCodeInfo {} + +impl GeneratedCodeInfo { + pub fn new() -> GeneratedCodeInfo { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static GeneratedCodeInfo { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const GeneratedCodeInfo, + }; + unsafe { + instance.get(GeneratedCodeInfo::new) + } + } + + // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1; + + pub fn clear_annotation(&mut self) { + self.annotation.clear(); + } + + // Param is passed by value, moved + pub fn set_annotation(&mut self, v: ::protobuf::RepeatedField) { + self.annotation = v; + } + + // Mutable pointer to the field. + pub fn mut_annotation(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.annotation + } + + // Take field + pub fn take_annotation(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.annotation, ::protobuf::RepeatedField::new()) + } + + pub fn get_annotation(&self) -> &[GeneratedCodeInfo_Annotation] { + &self.annotation + } + + fn get_annotation_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.annotation + } + + fn mut_annotation_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.annotation + } +} + +impl ::protobuf::Message for GeneratedCodeInfo { + fn is_initialized(&self) -> bool { + for v in &self.annotation { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.annotation)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + for value in &self.annotation { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + for v in &self.annotation { + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for GeneratedCodeInfo { + fn new() -> GeneratedCodeInfo { + GeneratedCodeInfo::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "annotation", + GeneratedCodeInfo::get_annotation_for_reflect, + GeneratedCodeInfo::mut_annotation_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "GeneratedCodeInfo", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for GeneratedCodeInfo { + fn clear(&mut self) { + self.clear_annotation(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for GeneratedCodeInfo { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for GeneratedCodeInfo { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct GeneratedCodeInfo_Annotation { + // message fields + path: ::std::vec::Vec, + source_file: ::protobuf::SingularField<::std::string::String>, + begin: ::std::option::Option, + end: ::std::option::Option, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for GeneratedCodeInfo_Annotation {} + +impl GeneratedCodeInfo_Annotation { + pub fn new() -> GeneratedCodeInfo_Annotation { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static GeneratedCodeInfo_Annotation { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const GeneratedCodeInfo_Annotation, + }; + unsafe { + instance.get(GeneratedCodeInfo_Annotation::new) + } + } + + // repeated int32 path = 1; + + pub fn clear_path(&mut self) { + self.path.clear(); + } + + // Param is passed by value, moved + pub fn set_path(&mut self, v: ::std::vec::Vec) { + self.path = v; + } + + // Mutable pointer to the field. + pub fn mut_path(&mut self) -> &mut ::std::vec::Vec { + &mut self.path + } + + // Take field + pub fn take_path(&mut self) -> ::std::vec::Vec { + ::std::mem::replace(&mut self.path, ::std::vec::Vec::new()) + } + + pub fn get_path(&self) -> &[i32] { + &self.path + } + + fn get_path_for_reflect(&self) -> &::std::vec::Vec { + &self.path + } + + fn mut_path_for_reflect(&mut self) -> &mut ::std::vec::Vec { + &mut self.path + } + + // optional string source_file = 2; + + pub fn clear_source_file(&mut self) { + self.source_file.clear(); + } + + pub fn has_source_file(&self) -> bool { + self.source_file.is_some() + } + + // Param is passed by value, moved + pub fn set_source_file(&mut self, v: ::std::string::String) { + self.source_file = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_source_file(&mut self) -> &mut ::std::string::String { + if self.source_file.is_none() { + self.source_file.set_default(); + } + self.source_file.as_mut().unwrap() + } + + // Take field + pub fn take_source_file(&mut self) -> ::std::string::String { + self.source_file.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_source_file(&self) -> &str { + match self.source_file.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_source_file_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.source_file + } + + fn mut_source_file_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.source_file + } + + // optional int32 begin = 3; + + pub fn clear_begin(&mut self) { + self.begin = ::std::option::Option::None; + } + + pub fn has_begin(&self) -> bool { + self.begin.is_some() + } + + // Param is passed by value, moved + pub fn set_begin(&mut self, v: i32) { + self.begin = ::std::option::Option::Some(v); + } + + pub fn get_begin(&self) -> i32 { + self.begin.unwrap_or(0) + } + + fn get_begin_for_reflect(&self) -> &::std::option::Option { + &self.begin + } + + fn mut_begin_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.begin + } + + // optional int32 end = 4; + + pub fn clear_end(&mut self) { + self.end = ::std::option::Option::None; + } + + pub fn has_end(&self) -> bool { + self.end.is_some() + } + + // Param is passed by value, moved + pub fn set_end(&mut self, v: i32) { + self.end = ::std::option::Option::Some(v); + } + + pub fn get_end(&self) -> i32 { + self.end.unwrap_or(0) + } + + fn get_end_for_reflect(&self) -> &::std::option::Option { + &self.end + } + + fn mut_end_for_reflect(&mut self) -> &mut ::std::option::Option { + &mut self.end + } +} + +impl ::protobuf::Message for GeneratedCodeInfo_Annotation { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_repeated_int32_into(wire_type, is, &mut self.path)?; + }, + 2 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.source_file)?; + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int32()?; + self.begin = ::std::option::Option::Some(tmp); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int32()?; + self.end = ::std::option::Option::Some(tmp); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.path.is_empty() { + my_size += ::protobuf::rt::vec_packed_varint_size(1, &self.path); + } + if let Some(ref v) = self.source_file.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + if let Some(v) = self.begin { + my_size += ::protobuf::rt::value_size(3, v, ::protobuf::wire_format::WireTypeVarint); + } + if let Some(v) = self.end { + my_size += ::protobuf::rt::value_size(4, v, ::protobuf::wire_format::WireTypeVarint); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.path.is_empty() { + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; + // TODO: Data size is computed again, it should be cached + os.write_raw_varint32(::protobuf::rt::vec_packed_varint_data_size(&self.path))?; + for v in &self.path { + os.write_int32_no_tag(*v)?; + }; + } + if let Some(ref v) = self.source_file.as_ref() { + os.write_string(2, &v)?; + } + if let Some(v) = self.begin { + os.write_int32(3, v)?; + } + if let Some(v) = self.end { + os.write_int32(4, v)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for GeneratedCodeInfo_Annotation { + fn new() -> GeneratedCodeInfo_Annotation { + GeneratedCodeInfo_Annotation::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_vec_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "path", + GeneratedCodeInfo_Annotation::get_path_for_reflect, + GeneratedCodeInfo_Annotation::mut_path_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "source_file", + GeneratedCodeInfo_Annotation::get_source_file_for_reflect, + GeneratedCodeInfo_Annotation::mut_source_file_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "begin", + GeneratedCodeInfo_Annotation::get_begin_for_reflect, + GeneratedCodeInfo_Annotation::mut_begin_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "end", + GeneratedCodeInfo_Annotation::get_end_for_reflect, + GeneratedCodeInfo_Annotation::mut_end_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "GeneratedCodeInfo_Annotation", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for GeneratedCodeInfo_Annotation { + fn clear(&mut self) { + self.clear_path(); + self.clear_source_file(); + self.clear_begin(); + self.clear_end(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for GeneratedCodeInfo_Annotation { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for GeneratedCodeInfo_Annotation { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x20google/protobuf/descriptor.proto\x12\x0fgoogle.protobuf\"M\n\x11Fi\ + leDescriptorSet\x128\n\x04file\x18\x01\x20\x03(\x0b2$.google.protobuf.Fi\ + leDescriptorProtoR\x04file\"\xe4\x04\n\x13FileDescriptorProto\x12\x12\n\ + \x04name\x18\x01\x20\x01(\tR\x04name\x12\x18\n\x07package\x18\x02\x20\ + \x01(\tR\x07package\x12\x1e\n\ndependency\x18\x03\x20\x03(\tR\ndependenc\ + y\x12+\n\x11public_dependency\x18\n\x20\x03(\x05R\x10publicDependency\ + \x12'\n\x0fweak_dependency\x18\x0b\x20\x03(\x05R\x0eweakDependency\x12C\ + \n\x0cmessage_type\x18\x04\x20\x03(\x0b2\x20.google.protobuf.DescriptorP\ + rotoR\x0bmessageType\x12A\n\tenum_type\x18\x05\x20\x03(\x0b2$.google.pro\ + tobuf.EnumDescriptorProtoR\x08enumType\x12A\n\x07service\x18\x06\x20\x03\ + (\x0b2'.google.protobuf.ServiceDescriptorProtoR\x07service\x12C\n\texten\ + sion\x18\x07\x20\x03(\x0b2%.google.protobuf.FieldDescriptorProtoR\texten\ + sion\x126\n\x07options\x18\x08\x20\x01(\x0b2\x1c.google.protobuf.FileOpt\ + ionsR\x07options\x12I\n\x10source_code_info\x18\t\x20\x01(\x0b2\x1f.goog\ + le.protobuf.SourceCodeInfoR\x0esourceCodeInfo\x12\x16\n\x06syntax\x18\ + \x0c\x20\x01(\tR\x06syntax\"\xf7\x05\n\x0fDescriptorProto\x12\x12\n\x04n\ + ame\x18\x01\x20\x01(\tR\x04name\x12;\n\x05field\x18\x02\x20\x03(\x0b2%.g\ + oogle.protobuf.FieldDescriptorProtoR\x05field\x12C\n\textension\x18\x06\ + \x20\x03(\x0b2%.google.protobuf.FieldDescriptorProtoR\textension\x12A\n\ + \x0bnested_type\x18\x03\x20\x03(\x0b2\x20.google.protobuf.DescriptorProt\ + oR\nnestedType\x12A\n\tenum_type\x18\x04\x20\x03(\x0b2$.google.protobuf.\ + EnumDescriptorProtoR\x08enumType\x12X\n\x0fextension_range\x18\x05\x20\ + \x03(\x0b2/.google.protobuf.DescriptorProto.ExtensionRangeR\x0eextension\ + Range\x12D\n\noneof_decl\x18\x08\x20\x03(\x0b2%.google.protobuf.OneofDes\ + criptorProtoR\toneofDecl\x129\n\x07options\x18\x07\x20\x01(\x0b2\x1f.goo\ + gle.protobuf.MessageOptionsR\x07options\x12U\n\x0ereserved_range\x18\t\ + \x20\x03(\x0b2..google.protobuf.DescriptorProto.ReservedRangeR\rreserved\ + Range\x12#\n\rreserved_name\x18\n\x20\x03(\tR\x0creservedName\x1a8\n\x0e\ + ExtensionRange\x12\x14\n\x05start\x18\x01\x20\x01(\x05R\x05start\x12\x10\ + \n\x03end\x18\x02\x20\x01(\x05R\x03end\x1a7\n\rReservedRange\x12\x14\n\ + \x05start\x18\x01\x20\x01(\x05R\x05start\x12\x10\n\x03end\x18\x02\x20\ + \x01(\x05R\x03end\"\x98\x06\n\x14FieldDescriptorProto\x12\x12\n\x04name\ + \x18\x01\x20\x01(\tR\x04name\x12\x16\n\x06number\x18\x03\x20\x01(\x05R\ + \x06number\x12A\n\x05label\x18\x04\x20\x01(\x0e2+.google.protobuf.FieldD\ + escriptorProto.LabelR\x05label\x12>\n\x04type\x18\x05\x20\x01(\x0e2*.goo\ + gle.protobuf.FieldDescriptorProto.TypeR\x04type\x12\x1b\n\ttype_name\x18\ + \x06\x20\x01(\tR\x08typeName\x12\x1a\n\x08extendee\x18\x02\x20\x01(\tR\ + \x08extendee\x12#\n\rdefault_value\x18\x07\x20\x01(\tR\x0cdefaultValue\ + \x12\x1f\n\x0boneof_index\x18\t\x20\x01(\x05R\noneofIndex\x12\x1b\n\tjso\ + n_name\x18\n\x20\x01(\tR\x08jsonName\x127\n\x07options\x18\x08\x20\x01(\ + \x0b2\x1d.google.protobuf.FieldOptionsR\x07options\"\xb6\x02\n\x04Type\ + \x12\x0f\n\x0bTYPE_DOUBLE\x10\x01\x12\x0e\n\nTYPE_FLOAT\x10\x02\x12\x0e\ + \n\nTYPE_INT64\x10\x03\x12\x0f\n\x0bTYPE_UINT64\x10\x04\x12\x0e\n\nTYPE_\ + INT32\x10\x05\x12\x10\n\x0cTYPE_FIXED64\x10\x06\x12\x10\n\x0cTYPE_FIXED3\ + 2\x10\x07\x12\r\n\tTYPE_BOOL\x10\x08\x12\x0f\n\x0bTYPE_STRING\x10\t\x12\ + \x0e\n\nTYPE_GROUP\x10\n\x12\x10\n\x0cTYPE_MESSAGE\x10\x0b\x12\x0e\n\nTY\ + PE_BYTES\x10\x0c\x12\x0f\n\x0bTYPE_UINT32\x10\r\x12\r\n\tTYPE_ENUM\x10\ + \x0e\x12\x11\n\rTYPE_SFIXED32\x10\x0f\x12\x11\n\rTYPE_SFIXED64\x10\x10\ + \x12\x0f\n\x0bTYPE_SINT32\x10\x11\x12\x0f\n\x0bTYPE_SINT64\x10\x12\"C\n\ + \x05Label\x12\x12\n\x0eLABEL_OPTIONAL\x10\x01\x12\x12\n\x0eLABEL_REQUIRE\ + D\x10\x02\x12\x12\n\x0eLABEL_REPEATED\x10\x03\"c\n\x14OneofDescriptorPro\ + to\x12\x12\n\x04name\x18\x01\x20\x01(\tR\x04name\x127\n\x07options\x18\ + \x02\x20\x01(\x0b2\x1d.google.protobuf.OneofOptionsR\x07options\"\xa2\ + \x01\n\x13EnumDescriptorProto\x12\x12\n\x04name\x18\x01\x20\x01(\tR\x04n\ + ame\x12?\n\x05value\x18\x02\x20\x03(\x0b2).google.protobuf.EnumValueDesc\ + riptorProtoR\x05value\x126\n\x07options\x18\x03\x20\x01(\x0b2\x1c.google\ + .protobuf.EnumOptionsR\x07options\"\x83\x01\n\x18EnumValueDescriptorProt\ + o\x12\x12\n\x04name\x18\x01\x20\x01(\tR\x04name\x12\x16\n\x06number\x18\ + \x02\x20\x01(\x05R\x06number\x12;\n\x07options\x18\x03\x20\x01(\x0b2!.go\ + ogle.protobuf.EnumValueOptionsR\x07options\"\xa7\x01\n\x16ServiceDescrip\ + torProto\x12\x12\n\x04name\x18\x01\x20\x01(\tR\x04name\x12>\n\x06method\ + \x18\x02\x20\x03(\x0b2&.google.protobuf.MethodDescriptorProtoR\x06method\ + \x129\n\x07options\x18\x03\x20\x01(\x0b2\x1f.google.protobuf.ServiceOpti\ + onsR\x07options\"\x89\x02\n\x15MethodDescriptorProto\x12\x12\n\x04name\ + \x18\x01\x20\x01(\tR\x04name\x12\x1d\n\ninput_type\x18\x02\x20\x01(\tR\t\ + inputType\x12\x1f\n\x0boutput_type\x18\x03\x20\x01(\tR\noutputType\x128\ + \n\x07options\x18\x04\x20\x01(\x0b2\x1e.google.protobuf.MethodOptionsR\ + \x07options\x120\n\x10client_streaming\x18\x05\x20\x01(\x08:\x05falseR\ + \x0fclientStreaming\x120\n\x10server_streaming\x18\x06\x20\x01(\x08:\x05\ + falseR\x0fserverStreaming\"\x88\x07\n\x0bFileOptions\x12!\n\x0cjava_pack\ + age\x18\x01\x20\x01(\tR\x0bjavaPackage\x120\n\x14java_outer_classname\ + \x18\x08\x20\x01(\tR\x12javaOuterClassname\x125\n\x13java_multiple_files\ + \x18\n\x20\x01(\x08:\x05falseR\x11javaMultipleFiles\x12D\n\x1djava_gener\ + ate_equals_and_hash\x18\x14\x20\x01(\x08R\x19javaGenerateEqualsAndHashB\ + \x02\x18\x01\x12:\n\x16java_string_check_utf8\x18\x1b\x20\x01(\x08:\x05f\ + alseR\x13javaStringCheckUtf8\x12S\n\x0coptimize_for\x18\t\x20\x01(\x0e2)\ + .google.protobuf.FileOptions.OptimizeMode:\x05SPEEDR\x0boptimizeFor\x12\ + \x1d\n\ngo_package\x18\x0b\x20\x01(\tR\tgoPackage\x125\n\x13cc_generic_s\ + ervices\x18\x10\x20\x01(\x08:\x05falseR\x11ccGenericServices\x129\n\x15j\ + ava_generic_services\x18\x11\x20\x01(\x08:\x05falseR\x13javaGenericServi\ + ces\x125\n\x13py_generic_services\x18\x12\x20\x01(\x08:\x05falseR\x11pyG\ + enericServices\x12%\n\ndeprecated\x18\x17\x20\x01(\x08:\x05falseR\ndepre\ + cated\x12/\n\x10cc_enable_arenas\x18\x1f\x20\x01(\x08:\x05falseR\x0eccEn\ + ableArenas\x12*\n\x11objc_class_prefix\x18$\x20\x01(\tR\x0fobjcClassPref\ + ix\x12)\n\x10csharp_namespace\x18%\x20\x01(\tR\x0fcsharpNamespace\x12X\n\ + \x14uninterpreted_option\x18\xe7\x07\x20\x03(\x0b2$.google.protobuf.Unin\ + terpretedOptionR\x13uninterpretedOption\":\n\x0cOptimizeMode\x12\t\n\x05\ + SPEED\x10\x01\x12\r\n\tCODE_SIZE\x10\x02\x12\x10\n\x0cLITE_RUNTIME\x10\ + \x03*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xc5\x02\n\x0eMessageOption\ + s\x12<\n\x17message_set_wire_format\x18\x01\x20\x01(\x08:\x05falseR\x14m\ + essageSetWireFormat\x12L\n\x1fno_standard_descriptor_accessor\x18\x02\ + \x20\x01(\x08:\x05falseR\x1cnoStandardDescriptorAccessor\x12%\n\ndepreca\ + ted\x18\x03\x20\x01(\x08:\x05falseR\ndeprecated\x12\x1b\n\tmap_entry\x18\ + \x07\x20\x01(\x08R\x08mapEntry\x12X\n\x14uninterpreted_option\x18\xe7\ + \x07\x20\x03(\x0b2$.google.protobuf.UninterpretedOptionR\x13uninterprete\ + dOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xdc\x03\n\x0cFieldOptio\ + ns\x12A\n\x05ctype\x18\x01\x20\x01(\x0e2#.google.protobuf.FieldOptions.C\ + Type:\x06STRINGR\x05ctype\x12\x16\n\x06packed\x18\x02\x20\x01(\x08R\x06p\ + acked\x12G\n\x06jstype\x18\x06\x20\x01(\x0e2$.google.protobuf.FieldOptio\ + ns.JSType:\tJS_NORMALR\x06jstype\x12\x19\n\x04lazy\x18\x05\x20\x01(\x08:\ + \x05falseR\x04lazy\x12%\n\ndeprecated\x18\x03\x20\x01(\x08:\x05falseR\nd\ + eprecated\x12\x19\n\x04weak\x18\n\x20\x01(\x08:\x05falseR\x04weak\x12X\n\ + \x14uninterpreted_option\x18\xe7\x07\x20\x03(\x0b2$.google.protobuf.Unin\ + terpretedOptionR\x13uninterpretedOption\"/\n\x05CType\x12\n\n\x06STRING\ + \x10\0\x12\x08\n\x04CORD\x10\x01\x12\x10\n\x0cSTRING_PIECE\x10\x02\"5\n\ + \x06JSType\x12\r\n\tJS_NORMAL\x10\0\x12\r\n\tJS_STRING\x10\x01\x12\r\n\t\ + JS_NUMBER\x10\x02*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"s\n\x0cOneofOp\ + tions\x12X\n\x14uninterpreted_option\x18\xe7\x07\x20\x03(\x0b2$.google.p\ + rotobuf.UninterpretedOptionR\x13uninterpretedOption*\t\x08\xe8\x07\x10\ + \x80\x80\x80\x80\x02\"\xba\x01\n\x0bEnumOptions\x12\x1f\n\x0ballow_alias\ + \x18\x02\x20\x01(\x08R\nallowAlias\x12%\n\ndeprecated\x18\x03\x20\x01(\ + \x08:\x05falseR\ndeprecated\x12X\n\x14uninterpreted_option\x18\xe7\x07\ + \x20\x03(\x0b2$.google.protobuf.UninterpretedOptionR\x13uninterpretedOpt\ + ion*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\x9e\x01\n\x10EnumValueOptio\ + ns\x12%\n\ndeprecated\x18\x01\x20\x01(\x08:\x05falseR\ndeprecated\x12X\n\ + \x14uninterpreted_option\x18\xe7\x07\x20\x03(\x0b2$.google.protobuf.Unin\ + terpretedOptionR\x13uninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\ + \x80\x02\"\x9c\x01\n\x0eServiceOptions\x12%\n\ndeprecated\x18!\x20\x01(\ + \x08:\x05falseR\ndeprecated\x12X\n\x14uninterpreted_option\x18\xe7\x07\ + \x20\x03(\x0b2$.google.protobuf.UninterpretedOptionR\x13uninterpretedOpt\ + ion*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\x9b\x01\n\rMethodOptions\ + \x12%\n\ndeprecated\x18!\x20\x01(\x08:\x05falseR\ndeprecated\x12X\n\x14u\ + ninterpreted_option\x18\xe7\x07\x20\x03(\x0b2$.google.protobuf.Uninterpr\ + etedOptionR\x13uninterpretedOption*\t\x08\xe8\x07\x10\x80\x80\x80\x80\ + \x02\"\x9a\x03\n\x13UninterpretedOption\x12A\n\x04name\x18\x02\x20\x03(\ + \x0b2-.google.protobuf.UninterpretedOption.NamePartR\x04name\x12)\n\x10i\ + dentifier_value\x18\x03\x20\x01(\tR\x0fidentifierValue\x12,\n\x12positiv\ + e_int_value\x18\x04\x20\x01(\x04R\x10positiveIntValue\x12,\n\x12negative\ + _int_value\x18\x05\x20\x01(\x03R\x10negativeIntValue\x12!\n\x0cdouble_va\ + lue\x18\x06\x20\x01(\x01R\x0bdoubleValue\x12!\n\x0cstring_value\x18\x07\ + \x20\x01(\x0cR\x0bstringValue\x12'\n\x0faggregate_value\x18\x08\x20\x01(\ + \tR\x0eaggregateValue\x1aJ\n\x08NamePart\x12\x1b\n\tname_part\x18\x01\ + \x20\x02(\tR\x08namePart\x12!\n\x0cis_extension\x18\x02\x20\x02(\x08R\ + \x0bisExtension\"\xa7\x02\n\x0eSourceCodeInfo\x12D\n\x08location\x18\x01\ + \x20\x03(\x0b2(.google.protobuf.SourceCodeInfo.LocationR\x08location\x1a\ + \xce\x01\n\x08Location\x12\x16\n\x04path\x18\x01\x20\x03(\x05R\x04pathB\ + \x02\x10\x01\x12\x16\n\x04span\x18\x02\x20\x03(\x05R\x04spanB\x02\x10\ + \x01\x12)\n\x10leading_comments\x18\x03\x20\x01(\tR\x0fleadingComments\ + \x12+\n\x11trailing_comments\x18\x04\x20\x01(\tR\x10trailingComments\x12\ + :\n\x19leading_detached_comments\x18\x06\x20\x03(\tR\x17leadingDetachedC\ + omments\"\xd1\x01\n\x11GeneratedCodeInfo\x12M\n\nannotation\x18\x01\x20\ + \x03(\x0b2-.google.protobuf.GeneratedCodeInfo.AnnotationR\nannotation\ + \x1am\n\nAnnotation\x12\x16\n\x04path\x18\x01\x20\x03(\x05R\x04pathB\x02\ + \x10\x01\x12\x1f\n\x0bsource_file\x18\x02\x20\x01(\tR\nsourceFile\x12\ + \x14\n\x05begin\x18\x03\x20\x01(\x05R\x05begin\x12\x10\n\x03end\x18\x04\ + \x20\x01(\x05R\x03endBX\n\x13com.google.protobufB\x10DescriptorProtosH\ + \x01Z\ndescriptor\xa2\x02\x03GPB\xaa\x02\x1aGoogle.Protobuf.ReflectionJ\ + \xfe\xa4\x02\n\x07\x12\x05'\0\xa3\x06\x01\n\xaa\x0f\n\x01\x0c\x12\x03'\0\ + \x122\xc1\x0c\x20Protocol\x20Buffers\x20-\x20Google's\x20data\x20interch\ + ange\x20format\n\x20Copyright\x202008\x20Google\x20Inc.\x20\x20All\x20ri\ + ghts\x20reserved.\n\x20https://developers.google.com/protocol-buffers/\n\ + \n\x20Redistribution\x20and\x20use\x20in\x20source\x20and\x20binary\x20f\ + orms,\x20with\x20or\x20without\n\x20modification,\x20are\x20permitted\ + \x20provided\x20that\x20the\x20following\x20conditions\x20are\n\x20met:\ + \n\n\x20\x20\x20\x20\x20*\x20Redistributions\x20of\x20source\x20code\x20\ + must\x20retain\x20the\x20above\x20copyright\n\x20notice,\x20this\x20list\ + \x20of\x20conditions\x20and\x20the\x20following\x20disclaimer.\n\x20\x20\ + \x20\x20\x20*\x20Redistributions\x20in\x20binary\x20form\x20must\x20repr\ + oduce\x20the\x20above\n\x20copyright\x20notice,\x20this\x20list\x20of\ + \x20conditions\x20and\x20the\x20following\x20disclaimer\n\x20in\x20the\ + \x20documentation\x20and/or\x20other\x20materials\x20provided\x20with\ + \x20the\n\x20distribution.\n\x20\x20\x20\x20\x20*\x20Neither\x20the\x20n\ + ame\x20of\x20Google\x20Inc.\x20nor\x20the\x20names\x20of\x20its\n\x20con\ + tributors\x20may\x20be\x20used\x20to\x20endorse\x20or\x20promote\x20prod\ + ucts\x20derived\x20from\n\x20this\x20software\x20without\x20specific\x20\ + prior\x20written\x20permission.\n\n\x20THIS\x20SOFTWARE\x20IS\x20PROVIDE\ + D\x20BY\x20THE\x20COPYRIGHT\x20HOLDERS\x20AND\x20CONTRIBUTORS\n\x20\"AS\ + \x20IS\"\x20AND\x20ANY\x20EXPRESS\x20OR\x20IMPLIED\x20WARRANTIES,\x20INC\ + LUDING,\x20BUT\x20NOT\n\x20LIMITED\x20TO,\x20THE\x20IMPLIED\x20WARRANTIE\ + S\x20OF\x20MERCHANTABILITY\x20AND\x20FITNESS\x20FOR\n\x20A\x20PARTICULAR\ + \x20PURPOSE\x20ARE\x20DISCLAIMED.\x20IN\x20NO\x20EVENT\x20SHALL\x20THE\ + \x20COPYRIGHT\n\x20OWNER\x20OR\x20CONTRIBUTORS\x20BE\x20LIABLE\x20FOR\ + \x20ANY\x20DIRECT,\x20INDIRECT,\x20INCIDENTAL,\n\x20SPECIAL,\x20EXEMPLAR\ + Y,\x20OR\x20CONSEQUENTIAL\x20DAMAGES\x20(INCLUDING,\x20BUT\x20NOT\n\x20L\ + IMITED\x20TO,\x20PROCUREMENT\x20OF\x20SUBSTITUTE\x20GOODS\x20OR\x20SERVI\ + CES;\x20LOSS\x20OF\x20USE,\n\x20DATA,\x20OR\x20PROFITS;\x20OR\x20BUSINES\ + S\x20INTERRUPTION)\x20HOWEVER\x20CAUSED\x20AND\x20ON\x20ANY\n\x20THEORY\ + \x20OF\x20LIABILITY,\x20WHETHER\x20IN\x20CONTRACT,\x20STRICT\x20LIABILIT\ + Y,\x20OR\x20TORT\n\x20(INCLUDING\x20NEGLIGENCE\x20OR\x20OTHERWISE)\x20AR\ + ISING\x20IN\x20ANY\x20WAY\x20OUT\x20OF\x20THE\x20USE\n\x20OF\x20THIS\x20\ + SOFTWARE,\x20EVEN\x20IF\x20ADVISED\x20OF\x20THE\x20POSSIBILITY\x20OF\x20\ + SUCH\x20DAMAGE.\n2\xdb\x02\x20Author:\x20kenton@google.com\x20(Kenton\ + \x20Varda)\n\x20\x20Based\x20on\x20original\x20Protocol\x20Buffers\x20de\ + sign\x20by\n\x20\x20Sanjay\x20Ghemawat,\x20Jeff\x20Dean,\x20and\x20other\ + s.\n\n\x20The\x20messages\x20in\x20this\x20file\x20describe\x20the\x20de\ + finitions\x20found\x20in\x20.proto\x20files.\n\x20A\x20valid\x20.proto\ + \x20file\x20can\x20be\x20translated\x20directly\x20to\x20a\x20FileDescri\ + ptorProto\n\x20without\x20any\x20other\x20information\x20(e.g.\x20withou\ + t\x20reading\x20its\x20imports).\n\n\x08\n\x01\x02\x12\x03)\x08\x17\n\ + \x08\n\x01\x08\x12\x03*\0!\n\x0b\n\x04\x08\xe7\x07\0\x12\x03*\0!\n\x0c\n\ + \x05\x08\xe7\x07\0\x02\x12\x03*\x07\x11\n\r\n\x06\x08\xe7\x07\0\x02\0\ + \x12\x03*\x07\x11\n\x0e\n\x07\x08\xe7\x07\0\x02\0\x01\x12\x03*\x07\x11\n\ + \x0c\n\x05\x08\xe7\x07\0\x07\x12\x03*\x14\x20\n\x08\n\x01\x08\x12\x03+\0\ + ,\n\x0b\n\x04\x08\xe7\x07\x01\x12\x03+\0,\n\x0c\n\x05\x08\xe7\x07\x01\ + \x02\x12\x03+\x07\x13\n\r\n\x06\x08\xe7\x07\x01\x02\0\x12\x03+\x07\x13\n\ + \x0e\n\x07\x08\xe7\x07\x01\x02\0\x01\x12\x03+\x07\x13\n\x0c\n\x05\x08\ + \xe7\x07\x01\x07\x12\x03+\x16+\n\x08\n\x01\x08\x12\x03,\01\n\x0b\n\x04\ + \x08\xe7\x07\x02\x12\x03,\01\n\x0c\n\x05\x08\xe7\x07\x02\x02\x12\x03,\ + \x07\x1b\n\r\n\x06\x08\xe7\x07\x02\x02\0\x12\x03,\x07\x1b\n\x0e\n\x07\ + \x08\xe7\x07\x02\x02\0\x01\x12\x03,\x07\x1b\n\x0c\n\x05\x08\xe7\x07\x02\ + \x07\x12\x03,\x1e0\n\x08\n\x01\x08\x12\x03-\07\n\x0b\n\x04\x08\xe7\x07\ + \x03\x12\x03-\07\n\x0c\n\x05\x08\xe7\x07\x03\x02\x12\x03-\x07\x17\n\r\n\ + \x06\x08\xe7\x07\x03\x02\0\x12\x03-\x07\x17\n\x0e\n\x07\x08\xe7\x07\x03\ + \x02\0\x01\x12\x03-\x07\x17\n\x0c\n\x05\x08\xe7\x07\x03\x07\x12\x03-\x1a\ + 6\n\x08\n\x01\x08\x12\x03.\0!\n\x0b\n\x04\x08\xe7\x07\x04\x12\x03.\0!\n\ + \x0c\n\x05\x08\xe7\x07\x04\x02\x12\x03.\x07\x18\n\r\n\x06\x08\xe7\x07\ + \x04\x02\0\x12\x03.\x07\x18\n\x0e\n\x07\x08\xe7\x07\x04\x02\0\x01\x12\ + \x03.\x07\x18\n\x0c\n\x05\x08\xe7\x07\x04\x07\x12\x03.\x1b\x20\n\x08\n\ + \x01\x08\x12\x032\0\x1c\n\x81\x01\n\x04\x08\xe7\x07\x05\x12\x032\0\x1c\ + \x1at\x20descriptor.proto\x20must\x20be\x20optimized\x20for\x20speed\x20\ + because\x20reflection-based\n\x20algorithms\x20don't\x20work\x20during\ + \x20bootstrapping.\n\n\x0c\n\x05\x08\xe7\x07\x05\x02\x12\x032\x07\x13\n\ + \r\n\x06\x08\xe7\x07\x05\x02\0\x12\x032\x07\x13\n\x0e\n\x07\x08\xe7\x07\ + \x05\x02\0\x01\x12\x032\x07\x13\n\x0c\n\x05\x08\xe7\x07\x05\x03\x12\x032\ + \x16\x1b\nj\n\x02\x04\0\x12\x046\08\x01\x1a^\x20The\x20protocol\x20compi\ + ler\x20can\x20output\x20a\x20FileDescriptorSet\x20containing\x20the\x20.\ + proto\n\x20files\x20it\x20parses.\n\n\n\n\x03\x04\0\x01\x12\x036\x08\x19\ + \n\x0b\n\x04\x04\0\x02\0\x12\x037\x02(\n\x0c\n\x05\x04\0\x02\0\x04\x12\ + \x037\x02\n\n\x0c\n\x05\x04\0\x02\0\x06\x12\x037\x0b\x1e\n\x0c\n\x05\x04\ + \0\x02\0\x01\x12\x037\x1f#\n\x0c\n\x05\x04\0\x02\0\x03\x12\x037&'\n/\n\ + \x02\x04\x01\x12\x04;\0X\x01\x1a#\x20Describes\x20a\x20complete\x20.prot\ + o\x20file.\n\n\n\n\x03\x04\x01\x01\x12\x03;\x08\x1b\n9\n\x04\x04\x01\x02\ + \0\x12\x03<\x02\x1b\",\x20file\x20name,\x20relative\x20to\x20root\x20of\ + \x20source\x20tree\n\n\x0c\n\x05\x04\x01\x02\0\x04\x12\x03<\x02\n\n\x0c\ + \n\x05\x04\x01\x02\0\x05\x12\x03<\x0b\x11\n\x0c\n\x05\x04\x01\x02\0\x01\ + \x12\x03<\x12\x16\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03<\x19\x1a\n*\n\ + \x04\x04\x01\x02\x01\x12\x03=\x02\x1e\"\x1d\x20e.g.\x20\"foo\",\x20\"foo\ + .bar\",\x20etc.\n\n\x0c\n\x05\x04\x01\x02\x01\x04\x12\x03=\x02\n\n\x0c\n\ + \x05\x04\x01\x02\x01\x05\x12\x03=\x0b\x11\n\x0c\n\x05\x04\x01\x02\x01\ + \x01\x12\x03=\x12\x19\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03=\x1c\x1d\n\ + 4\n\x04\x04\x01\x02\x02\x12\x03@\x02!\x1a'\x20Names\x20of\x20files\x20im\ + ported\x20by\x20this\x20file.\n\n\x0c\n\x05\x04\x01\x02\x02\x04\x12\x03@\ + \x02\n\n\x0c\n\x05\x04\x01\x02\x02\x05\x12\x03@\x0b\x11\n\x0c\n\x05\x04\ + \x01\x02\x02\x01\x12\x03@\x12\x1c\n\x0c\n\x05\x04\x01\x02\x02\x03\x12\ + \x03@\x1f\x20\nQ\n\x04\x04\x01\x02\x03\x12\x03B\x02(\x1aD\x20Indexes\x20\ + of\x20the\x20public\x20imported\x20files\x20in\x20the\x20dependency\x20l\ + ist\x20above.\n\n\x0c\n\x05\x04\x01\x02\x03\x04\x12\x03B\x02\n\n\x0c\n\ + \x05\x04\x01\x02\x03\x05\x12\x03B\x0b\x10\n\x0c\n\x05\x04\x01\x02\x03\ + \x01\x12\x03B\x11\"\n\x0c\n\x05\x04\x01\x02\x03\x03\x12\x03B%'\nz\n\x04\ + \x04\x01\x02\x04\x12\x03E\x02&\x1am\x20Indexes\x20of\x20the\x20weak\x20i\ + mported\x20files\x20in\x20the\x20dependency\x20list.\n\x20For\x20Google-\ + internal\x20migration\x20only.\x20Do\x20not\x20use.\n\n\x0c\n\x05\x04\ + \x01\x02\x04\x04\x12\x03E\x02\n\n\x0c\n\x05\x04\x01\x02\x04\x05\x12\x03E\ + \x0b\x10\n\x0c\n\x05\x04\x01\x02\x04\x01\x12\x03E\x11\x20\n\x0c\n\x05\ + \x04\x01\x02\x04\x03\x12\x03E#%\n6\n\x04\x04\x01\x02\x05\x12\x03H\x02,\ + \x1a)\x20All\x20top-level\x20definitions\x20in\x20this\x20file.\n\n\x0c\ + \n\x05\x04\x01\x02\x05\x04\x12\x03H\x02\n\n\x0c\n\x05\x04\x01\x02\x05\ + \x06\x12\x03H\x0b\x1a\n\x0c\n\x05\x04\x01\x02\x05\x01\x12\x03H\x1b'\n\ + \x0c\n\x05\x04\x01\x02\x05\x03\x12\x03H*+\n\x0b\n\x04\x04\x01\x02\x06\ + \x12\x03I\x02-\n\x0c\n\x05\x04\x01\x02\x06\x04\x12\x03I\x02\n\n\x0c\n\ + \x05\x04\x01\x02\x06\x06\x12\x03I\x0b\x1e\n\x0c\n\x05\x04\x01\x02\x06\ + \x01\x12\x03I\x1f(\n\x0c\n\x05\x04\x01\x02\x06\x03\x12\x03I+,\n\x0b\n\ + \x04\x04\x01\x02\x07\x12\x03J\x02.\n\x0c\n\x05\x04\x01\x02\x07\x04\x12\ + \x03J\x02\n\n\x0c\n\x05\x04\x01\x02\x07\x06\x12\x03J\x0b!\n\x0c\n\x05\ + \x04\x01\x02\x07\x01\x12\x03J\")\n\x0c\n\x05\x04\x01\x02\x07\x03\x12\x03\ + J,-\n\x0b\n\x04\x04\x01\x02\x08\x12\x03K\x02.\n\x0c\n\x05\x04\x01\x02\ + \x08\x04\x12\x03K\x02\n\n\x0c\n\x05\x04\x01\x02\x08\x06\x12\x03K\x0b\x1f\ + \n\x0c\n\x05\x04\x01\x02\x08\x01\x12\x03K\x20)\n\x0c\n\x05\x04\x01\x02\ + \x08\x03\x12\x03K,-\n\x0b\n\x04\x04\x01\x02\t\x12\x03M\x02#\n\x0c\n\x05\ + \x04\x01\x02\t\x04\x12\x03M\x02\n\n\x0c\n\x05\x04\x01\x02\t\x06\x12\x03M\ + \x0b\x16\n\x0c\n\x05\x04\x01\x02\t\x01\x12\x03M\x17\x1e\n\x0c\n\x05\x04\ + \x01\x02\t\x03\x12\x03M!\"\n\xf4\x01\n\x04\x04\x01\x02\n\x12\x03S\x02/\ + \x1a\xe6\x01\x20This\x20field\x20contains\x20optional\x20information\x20\ + about\x20the\x20original\x20source\x20code.\n\x20You\x20may\x20safely\ + \x20remove\x20this\x20entire\x20field\x20without\x20harming\x20runtime\n\ + \x20functionality\x20of\x20the\x20descriptors\x20--\x20the\x20informatio\ + n\x20is\x20needed\x20only\x20by\n\x20development\x20tools.\n\n\x0c\n\x05\ + \x04\x01\x02\n\x04\x12\x03S\x02\n\n\x0c\n\x05\x04\x01\x02\n\x06\x12\x03S\ + \x0b\x19\n\x0c\n\x05\x04\x01\x02\n\x01\x12\x03S\x1a*\n\x0c\n\x05\x04\x01\ + \x02\n\x03\x12\x03S-.\n]\n\x04\x04\x01\x02\x0b\x12\x03W\x02\x1e\x1aP\x20\ + The\x20syntax\x20of\x20the\x20proto\x20file.\n\x20The\x20supported\x20va\ + lues\x20are\x20\"proto2\"\x20and\x20\"proto3\".\n\n\x0c\n\x05\x04\x01\ + \x02\x0b\x04\x12\x03W\x02\n\n\x0c\n\x05\x04\x01\x02\x0b\x05\x12\x03W\x0b\ + \x11\n\x0c\n\x05\x04\x01\x02\x0b\x01\x12\x03W\x12\x18\n\x0c\n\x05\x04\ + \x01\x02\x0b\x03\x12\x03W\x1b\x1d\n'\n\x02\x04\x02\x12\x04[\0y\x01\x1a\ + \x1b\x20Describes\x20a\x20message\x20type.\n\n\n\n\x03\x04\x02\x01\x12\ + \x03[\x08\x17\n\x0b\n\x04\x04\x02\x02\0\x12\x03\\\x02\x1b\n\x0c\n\x05\ + \x04\x02\x02\0\x04\x12\x03\\\x02\n\n\x0c\n\x05\x04\x02\x02\0\x05\x12\x03\ + \\\x0b\x11\n\x0c\n\x05\x04\x02\x02\0\x01\x12\x03\\\x12\x16\n\x0c\n\x05\ + \x04\x02\x02\0\x03\x12\x03\\\x19\x1a\n\x0b\n\x04\x04\x02\x02\x01\x12\x03\ + ^\x02*\n\x0c\n\x05\x04\x02\x02\x01\x04\x12\x03^\x02\n\n\x0c\n\x05\x04\ + \x02\x02\x01\x06\x12\x03^\x0b\x1f\n\x0c\n\x05\x04\x02\x02\x01\x01\x12\ + \x03^\x20%\n\x0c\n\x05\x04\x02\x02\x01\x03\x12\x03^()\n\x0b\n\x04\x04\ + \x02\x02\x02\x12\x03_\x02.\n\x0c\n\x05\x04\x02\x02\x02\x04\x12\x03_\x02\ + \n\n\x0c\n\x05\x04\x02\x02\x02\x06\x12\x03_\x0b\x1f\n\x0c\n\x05\x04\x02\ + \x02\x02\x01\x12\x03_\x20)\n\x0c\n\x05\x04\x02\x02\x02\x03\x12\x03_,-\n\ + \x0b\n\x04\x04\x02\x02\x03\x12\x03a\x02+\n\x0c\n\x05\x04\x02\x02\x03\x04\ + \x12\x03a\x02\n\n\x0c\n\x05\x04\x02\x02\x03\x06\x12\x03a\x0b\x1a\n\x0c\n\ + \x05\x04\x02\x02\x03\x01\x12\x03a\x1b&\n\x0c\n\x05\x04\x02\x02\x03\x03\ + \x12\x03a)*\n\x0b\n\x04\x04\x02\x02\x04\x12\x03b\x02-\n\x0c\n\x05\x04\ + \x02\x02\x04\x04\x12\x03b\x02\n\n\x0c\n\x05\x04\x02\x02\x04\x06\x12\x03b\ + \x0b\x1e\n\x0c\n\x05\x04\x02\x02\x04\x01\x12\x03b\x1f(\n\x0c\n\x05\x04\ + \x02\x02\x04\x03\x12\x03b+,\n\x0c\n\x04\x04\x02\x03\0\x12\x04d\x02g\x03\ + \n\x0c\n\x05\x04\x02\x03\0\x01\x12\x03d\n\x18\n\r\n\x06\x04\x02\x03\0\ + \x02\0\x12\x03e\x04\x1d\n\x0e\n\x07\x04\x02\x03\0\x02\0\x04\x12\x03e\x04\ + \x0c\n\x0e\n\x07\x04\x02\x03\0\x02\0\x05\x12\x03e\r\x12\n\x0e\n\x07\x04\ + \x02\x03\0\x02\0\x01\x12\x03e\x13\x18\n\x0e\n\x07\x04\x02\x03\0\x02\0\ + \x03\x12\x03e\x1b\x1c\n\r\n\x06\x04\x02\x03\0\x02\x01\x12\x03f\x04\x1b\n\ + \x0e\n\x07\x04\x02\x03\0\x02\x01\x04\x12\x03f\x04\x0c\n\x0e\n\x07\x04\ + \x02\x03\0\x02\x01\x05\x12\x03f\r\x12\n\x0e\n\x07\x04\x02\x03\0\x02\x01\ + \x01\x12\x03f\x13\x16\n\x0e\n\x07\x04\x02\x03\0\x02\x01\x03\x12\x03f\x19\ + \x1a\n\x0b\n\x04\x04\x02\x02\x05\x12\x03h\x02.\n\x0c\n\x05\x04\x02\x02\ + \x05\x04\x12\x03h\x02\n\n\x0c\n\x05\x04\x02\x02\x05\x06\x12\x03h\x0b\x19\ + \n\x0c\n\x05\x04\x02\x02\x05\x01\x12\x03h\x1a)\n\x0c\n\x05\x04\x02\x02\ + \x05\x03\x12\x03h,-\n\x0b\n\x04\x04\x02\x02\x06\x12\x03j\x02/\n\x0c\n\ + \x05\x04\x02\x02\x06\x04\x12\x03j\x02\n\n\x0c\n\x05\x04\x02\x02\x06\x06\ + \x12\x03j\x0b\x1f\n\x0c\n\x05\x04\x02\x02\x06\x01\x12\x03j\x20*\n\x0c\n\ + \x05\x04\x02\x02\x06\x03\x12\x03j-.\n\x0b\n\x04\x04\x02\x02\x07\x12\x03l\ + \x02&\n\x0c\n\x05\x04\x02\x02\x07\x04\x12\x03l\x02\n\n\x0c\n\x05\x04\x02\ + \x02\x07\x06\x12\x03l\x0b\x19\n\x0c\n\x05\x04\x02\x02\x07\x01\x12\x03l\ + \x1a!\n\x0c\n\x05\x04\x02\x02\x07\x03\x12\x03l$%\n\xaa\x01\n\x04\x04\x02\ + \x03\x01\x12\x04q\x02t\x03\x1a\x9b\x01\x20Range\x20of\x20reserved\x20tag\ + \x20numbers.\x20Reserved\x20tag\x20numbers\x20may\x20not\x20be\x20used\ + \x20by\n\x20fields\x20or\x20extension\x20ranges\x20in\x20the\x20same\x20\ + message.\x20Reserved\x20ranges\x20may\n\x20not\x20overlap.\n\n\x0c\n\x05\ + \x04\x02\x03\x01\x01\x12\x03q\n\x17\n\x1b\n\x06\x04\x02\x03\x01\x02\0\ + \x12\x03r\x04\x1d\"\x0c\x20Inclusive.\n\n\x0e\n\x07\x04\x02\x03\x01\x02\ + \0\x04\x12\x03r\x04\x0c\n\x0e\n\x07\x04\x02\x03\x01\x02\0\x05\x12\x03r\r\ + \x12\n\x0e\n\x07\x04\x02\x03\x01\x02\0\x01\x12\x03r\x13\x18\n\x0e\n\x07\ + \x04\x02\x03\x01\x02\0\x03\x12\x03r\x1b\x1c\n\x1b\n\x06\x04\x02\x03\x01\ + \x02\x01\x12\x03s\x04\x1b\"\x0c\x20Exclusive.\n\n\x0e\n\x07\x04\x02\x03\ + \x01\x02\x01\x04\x12\x03s\x04\x0c\n\x0e\n\x07\x04\x02\x03\x01\x02\x01\ + \x05\x12\x03s\r\x12\n\x0e\n\x07\x04\x02\x03\x01\x02\x01\x01\x12\x03s\x13\ + \x16\n\x0e\n\x07\x04\x02\x03\x01\x02\x01\x03\x12\x03s\x19\x1a\n\x0b\n\ + \x04\x04\x02\x02\x08\x12\x03u\x02,\n\x0c\n\x05\x04\x02\x02\x08\x04\x12\ + \x03u\x02\n\n\x0c\n\x05\x04\x02\x02\x08\x06\x12\x03u\x0b\x18\n\x0c\n\x05\ + \x04\x02\x02\x08\x01\x12\x03u\x19'\n\x0c\n\x05\x04\x02\x02\x08\x03\x12\ + \x03u*+\n\x82\x01\n\x04\x04\x02\x02\t\x12\x03x\x02%\x1au\x20Reserved\x20\ + field\x20names,\x20which\x20may\x20not\x20be\x20used\x20by\x20fields\x20\ + in\x20the\x20same\x20message.\n\x20A\x20given\x20name\x20may\x20only\x20\ + be\x20reserved\x20once.\n\n\x0c\n\x05\x04\x02\x02\t\x04\x12\x03x\x02\n\n\ + \x0c\n\x05\x04\x02\x02\t\x05\x12\x03x\x0b\x11\n\x0c\n\x05\x04\x02\x02\t\ + \x01\x12\x03x\x12\x1f\n\x0c\n\x05\x04\x02\x02\t\x03\x12\x03x\"$\n2\n\x02\ + \x04\x03\x12\x05|\0\xc7\x01\x01\x1a%\x20Describes\x20a\x20field\x20withi\ + n\x20a\x20message.\n\n\n\n\x03\x04\x03\x01\x12\x03|\x08\x1c\n\r\n\x04\ + \x04\x03\x04\0\x12\x05}\x02\x98\x01\x03\n\x0c\n\x05\x04\x03\x04\0\x01\ + \x12\x03}\x07\x0b\nS\n\x06\x04\x03\x04\0\x02\0\x12\x04\x80\x01\x04\x1c\ + \x1aC\x200\x20is\x20reserved\x20for\x20errors.\n\x20Order\x20is\x20weird\ + \x20for\x20historical\x20reasons.\n\n\x0f\n\x07\x04\x03\x04\0\x02\0\x01\ + \x12\x04\x80\x01\x04\x0f\n\x0f\n\x07\x04\x03\x04\0\x02\0\x02\x12\x04\x80\ + \x01\x1a\x1b\n\x0e\n\x06\x04\x03\x04\0\x02\x01\x12\x04\x81\x01\x04\x1c\n\ + \x0f\n\x07\x04\x03\x04\0\x02\x01\x01\x12\x04\x81\x01\x04\x0e\n\x0f\n\x07\ + \x04\x03\x04\0\x02\x01\x02\x12\x04\x81\x01\x1a\x1b\nw\n\x06\x04\x03\x04\ + \0\x02\x02\x12\x04\x84\x01\x04\x1c\x1ag\x20Not\x20ZigZag\x20encoded.\x20\ + \x20Negative\x20numbers\x20take\x2010\x20bytes.\x20\x20Use\x20TYPE_SINT6\ + 4\x20if\n\x20negative\x20values\x20are\x20likely.\n\n\x0f\n\x07\x04\x03\ + \x04\0\x02\x02\x01\x12\x04\x84\x01\x04\x0e\n\x0f\n\x07\x04\x03\x04\0\x02\ + \x02\x02\x12\x04\x84\x01\x1a\x1b\n\x0e\n\x06\x04\x03\x04\0\x02\x03\x12\ + \x04\x85\x01\x04\x1c\n\x0f\n\x07\x04\x03\x04\0\x02\x03\x01\x12\x04\x85\ + \x01\x04\x0f\n\x0f\n\x07\x04\x03\x04\0\x02\x03\x02\x12\x04\x85\x01\x1a\ + \x1b\nw\n\x06\x04\x03\x04\0\x02\x04\x12\x04\x88\x01\x04\x1c\x1ag\x20Not\ + \x20ZigZag\x20encoded.\x20\x20Negative\x20numbers\x20take\x2010\x20bytes\ + .\x20\x20Use\x20TYPE_SINT32\x20if\n\x20negative\x20values\x20are\x20like\ + ly.\n\n\x0f\n\x07\x04\x03\x04\0\x02\x04\x01\x12\x04\x88\x01\x04\x0e\n\ + \x0f\n\x07\x04\x03\x04\0\x02\x04\x02\x12\x04\x88\x01\x1a\x1b\n\x0e\n\x06\ + \x04\x03\x04\0\x02\x05\x12\x04\x89\x01\x04\x1c\n\x0f\n\x07\x04\x03\x04\0\ + \x02\x05\x01\x12\x04\x89\x01\x04\x10\n\x0f\n\x07\x04\x03\x04\0\x02\x05\ + \x02\x12\x04\x89\x01\x1a\x1b\n\x0e\n\x06\x04\x03\x04\0\x02\x06\x12\x04\ + \x8a\x01\x04\x1c\n\x0f\n\x07\x04\x03\x04\0\x02\x06\x01\x12\x04\x8a\x01\ + \x04\x10\n\x0f\n\x07\x04\x03\x04\0\x02\x06\x02\x12\x04\x8a\x01\x1a\x1b\n\ + \x0e\n\x06\x04\x03\x04\0\x02\x07\x12\x04\x8b\x01\x04\x1c\n\x0f\n\x07\x04\ + \x03\x04\0\x02\x07\x01\x12\x04\x8b\x01\x04\r\n\x0f\n\x07\x04\x03\x04\0\ + \x02\x07\x02\x12\x04\x8b\x01\x1a\x1b\n\x0e\n\x06\x04\x03\x04\0\x02\x08\ + \x12\x04\x8c\x01\x04\x1c\n\x0f\n\x07\x04\x03\x04\0\x02\x08\x01\x12\x04\ + \x8c\x01\x04\x0f\n\x0f\n\x07\x04\x03\x04\0\x02\x08\x02\x12\x04\x8c\x01\ + \x1a\x1b\n*\n\x06\x04\x03\x04\0\x02\t\x12\x04\x8d\x01\x04\x1d\"\x1a\x20T\ + ag-delimited\x20aggregate.\n\n\x0f\n\x07\x04\x03\x04\0\x02\t\x01\x12\x04\ + \x8d\x01\x04\x0e\n\x0f\n\x07\x04\x03\x04\0\x02\t\x02\x12\x04\x8d\x01\x1a\ + \x1c\n-\n\x06\x04\x03\x04\0\x02\n\x12\x04\x8e\x01\x04\x1d\"\x1d\x20Lengt\ + h-delimited\x20aggregate.\n\n\x0f\n\x07\x04\x03\x04\0\x02\n\x01\x12\x04\ + \x8e\x01\x04\x10\n\x0f\n\x07\x04\x03\x04\0\x02\n\x02\x12\x04\x8e\x01\x1a\ + \x1c\n#\n\x06\x04\x03\x04\0\x02\x0b\x12\x04\x91\x01\x04\x1d\x1a\x13\x20N\ + ew\x20in\x20version\x202.\n\n\x0f\n\x07\x04\x03\x04\0\x02\x0b\x01\x12\ + \x04\x91\x01\x04\x0e\n\x0f\n\x07\x04\x03\x04\0\x02\x0b\x02\x12\x04\x91\ + \x01\x1a\x1c\n\x0e\n\x06\x04\x03\x04\0\x02\x0c\x12\x04\x92\x01\x04\x1d\n\ + \x0f\n\x07\x04\x03\x04\0\x02\x0c\x01\x12\x04\x92\x01\x04\x0f\n\x0f\n\x07\ + \x04\x03\x04\0\x02\x0c\x02\x12\x04\x92\x01\x1a\x1c\n\x0e\n\x06\x04\x03\ + \x04\0\x02\r\x12\x04\x93\x01\x04\x1d\n\x0f\n\x07\x04\x03\x04\0\x02\r\x01\ + \x12\x04\x93\x01\x04\r\n\x0f\n\x07\x04\x03\x04\0\x02\r\x02\x12\x04\x93\ + \x01\x1a\x1c\n\x0e\n\x06\x04\x03\x04\0\x02\x0e\x12\x04\x94\x01\x04\x1d\n\ + \x0f\n\x07\x04\x03\x04\0\x02\x0e\x01\x12\x04\x94\x01\x04\x11\n\x0f\n\x07\ + \x04\x03\x04\0\x02\x0e\x02\x12\x04\x94\x01\x1a\x1c\n\x0e\n\x06\x04\x03\ + \x04\0\x02\x0f\x12\x04\x95\x01\x04\x1d\n\x0f\n\x07\x04\x03\x04\0\x02\x0f\ + \x01\x12\x04\x95\x01\x04\x11\n\x0f\n\x07\x04\x03\x04\0\x02\x0f\x02\x12\ + \x04\x95\x01\x1a\x1c\n'\n\x06\x04\x03\x04\0\x02\x10\x12\x04\x96\x01\x04\ + \x1d\"\x17\x20Uses\x20ZigZag\x20encoding.\n\n\x0f\n\x07\x04\x03\x04\0\ + \x02\x10\x01\x12\x04\x96\x01\x04\x0f\n\x0f\n\x07\x04\x03\x04\0\x02\x10\ + \x02\x12\x04\x96\x01\x1a\x1c\n'\n\x06\x04\x03\x04\0\x02\x11\x12\x04\x97\ + \x01\x04\x1d\"\x17\x20Uses\x20ZigZag\x20encoding.\n\n\x0f\n\x07\x04\x03\ + \x04\0\x02\x11\x01\x12\x04\x97\x01\x04\x0f\n\x0f\n\x07\x04\x03\x04\0\x02\ + \x11\x02\x12\x04\x97\x01\x1a\x1c\n\x0e\n\x04\x04\x03\x04\x01\x12\x06\x9a\ + \x01\x02\xa0\x01\x03\n\r\n\x05\x04\x03\x04\x01\x01\x12\x04\x9a\x01\x07\ + \x0c\n*\n\x06\x04\x03\x04\x01\x02\0\x12\x04\x9c\x01\x04\x1c\x1a\x1a\x200\ + \x20is\x20reserved\x20for\x20errors\n\n\x0f\n\x07\x04\x03\x04\x01\x02\0\ + \x01\x12\x04\x9c\x01\x04\x12\n\x0f\n\x07\x04\x03\x04\x01\x02\0\x02\x12\ + \x04\x9c\x01\x1a\x1b\n\x0e\n\x06\x04\x03\x04\x01\x02\x01\x12\x04\x9d\x01\ + \x04\x1c\n\x0f\n\x07\x04\x03\x04\x01\x02\x01\x01\x12\x04\x9d\x01\x04\x12\ + \n\x0f\n\x07\x04\x03\x04\x01\x02\x01\x02\x12\x04\x9d\x01\x1a\x1b\n8\n\ + \x06\x04\x03\x04\x01\x02\x02\x12\x04\x9e\x01\x04\x1c\"(\x20TODO(sanjay):\ + \x20Should\x20we\x20add\x20LABEL_MAP?\n\n\x0f\n\x07\x04\x03\x04\x01\x02\ + \x02\x01\x12\x04\x9e\x01\x04\x12\n\x0f\n\x07\x04\x03\x04\x01\x02\x02\x02\ + \x12\x04\x9e\x01\x1a\x1b\n\x0c\n\x04\x04\x03\x02\0\x12\x04\xa2\x01\x02\ + \x1b\n\r\n\x05\x04\x03\x02\0\x04\x12\x04\xa2\x01\x02\n\n\r\n\x05\x04\x03\ + \x02\0\x05\x12\x04\xa2\x01\x0b\x11\n\r\n\x05\x04\x03\x02\0\x01\x12\x04\ + \xa2\x01\x12\x16\n\r\n\x05\x04\x03\x02\0\x03\x12\x04\xa2\x01\x19\x1a\n\ + \x0c\n\x04\x04\x03\x02\x01\x12\x04\xa3\x01\x02\x1c\n\r\n\x05\x04\x03\x02\ + \x01\x04\x12\x04\xa3\x01\x02\n\n\r\n\x05\x04\x03\x02\x01\x05\x12\x04\xa3\ + \x01\x0b\x10\n\r\n\x05\x04\x03\x02\x01\x01\x12\x04\xa3\x01\x11\x17\n\r\n\ + \x05\x04\x03\x02\x01\x03\x12\x04\xa3\x01\x1a\x1b\n\x0c\n\x04\x04\x03\x02\ + \x02\x12\x04\xa4\x01\x02\x1b\n\r\n\x05\x04\x03\x02\x02\x04\x12\x04\xa4\ + \x01\x02\n\n\r\n\x05\x04\x03\x02\x02\x06\x12\x04\xa4\x01\x0b\x10\n\r\n\ + \x05\x04\x03\x02\x02\x01\x12\x04\xa4\x01\x11\x16\n\r\n\x05\x04\x03\x02\ + \x02\x03\x12\x04\xa4\x01\x19\x1a\n\x9c\x01\n\x04\x04\x03\x02\x03\x12\x04\ + \xa8\x01\x02\x19\x1a\x8d\x01\x20If\x20type_name\x20is\x20set,\x20this\ + \x20need\x20not\x20be\x20set.\x20\x20If\x20both\x20this\x20and\x20type_n\ + ame\n\x20are\x20set,\x20this\x20must\x20be\x20one\x20of\x20TYPE_ENUM,\ + \x20TYPE_MESSAGE\x20or\x20TYPE_GROUP.\n\n\r\n\x05\x04\x03\x02\x03\x04\ + \x12\x04\xa8\x01\x02\n\n\r\n\x05\x04\x03\x02\x03\x06\x12\x04\xa8\x01\x0b\ + \x0f\n\r\n\x05\x04\x03\x02\x03\x01\x12\x04\xa8\x01\x10\x14\n\r\n\x05\x04\ + \x03\x02\x03\x03\x12\x04\xa8\x01\x17\x18\n\xb7\x02\n\x04\x04\x03\x02\x04\ + \x12\x04\xaf\x01\x02\x20\x1a\xa8\x02\x20For\x20message\x20and\x20enum\ + \x20types,\x20this\x20is\x20the\x20name\x20of\x20the\x20type.\x20\x20If\ + \x20the\x20name\n\x20starts\x20with\x20a\x20'.',\x20it\x20is\x20fully-qu\ + alified.\x20\x20Otherwise,\x20C++-like\x20scoping\n\x20rules\x20are\x20u\ + sed\x20to\x20find\x20the\x20type\x20(i.e.\x20first\x20the\x20nested\x20t\ + ypes\x20within\x20this\n\x20message\x20are\x20searched,\x20then\x20withi\ + n\x20the\x20parent,\x20on\x20up\x20to\x20the\x20root\n\x20namespace).\n\ + \n\r\n\x05\x04\x03\x02\x04\x04\x12\x04\xaf\x01\x02\n\n\r\n\x05\x04\x03\ + \x02\x04\x05\x12\x04\xaf\x01\x0b\x11\n\r\n\x05\x04\x03\x02\x04\x01\x12\ + \x04\xaf\x01\x12\x1b\n\r\n\x05\x04\x03\x02\x04\x03\x12\x04\xaf\x01\x1e\ + \x1f\n~\n\x04\x04\x03\x02\x05\x12\x04\xb3\x01\x02\x1f\x1ap\x20For\x20ext\ + ensions,\x20this\x20is\x20the\x20name\x20of\x20the\x20type\x20being\x20e\ + xtended.\x20\x20It\x20is\n\x20resolved\x20in\x20the\x20same\x20manner\ + \x20as\x20type_name.\n\n\r\n\x05\x04\x03\x02\x05\x04\x12\x04\xb3\x01\x02\ + \n\n\r\n\x05\x04\x03\x02\x05\x05\x12\x04\xb3\x01\x0b\x11\n\r\n\x05\x04\ + \x03\x02\x05\x01\x12\x04\xb3\x01\x12\x1a\n\r\n\x05\x04\x03\x02\x05\x03\ + \x12\x04\xb3\x01\x1d\x1e\n\xb1\x02\n\x04\x04\x03\x02\x06\x12\x04\xba\x01\ + \x02$\x1a\xa2\x02\x20For\x20numeric\x20types,\x20contains\x20the\x20orig\ + inal\x20text\x20representation\x20of\x20the\x20value.\n\x20For\x20boolea\ + ns,\x20\"true\"\x20or\x20\"false\".\n\x20For\x20strings,\x20contains\x20\ + the\x20default\x20text\x20contents\x20(not\x20escaped\x20in\x20any\x20wa\ + y).\n\x20For\x20bytes,\x20contains\x20the\x20C\x20escaped\x20value.\x20\ + \x20All\x20bytes\x20>=\x20128\x20are\x20escaped.\n\x20TODO(kenton):\x20\ + \x20Base-64\x20encode?\n\n\r\n\x05\x04\x03\x02\x06\x04\x12\x04\xba\x01\ + \x02\n\n\r\n\x05\x04\x03\x02\x06\x05\x12\x04\xba\x01\x0b\x11\n\r\n\x05\ + \x04\x03\x02\x06\x01\x12\x04\xba\x01\x12\x1f\n\r\n\x05\x04\x03\x02\x06\ + \x03\x12\x04\xba\x01\"#\n\x84\x01\n\x04\x04\x03\x02\x07\x12\x04\xbe\x01\ + \x02!\x1av\x20If\x20set,\x20gives\x20the\x20index\x20of\x20a\x20oneof\ + \x20in\x20the\x20containing\x20type's\x20oneof_decl\n\x20list.\x20\x20Th\ + is\x20field\x20is\x20a\x20member\x20of\x20that\x20oneof.\n\n\r\n\x05\x04\ + \x03\x02\x07\x04\x12\x04\xbe\x01\x02\n\n\r\n\x05\x04\x03\x02\x07\x05\x12\ + \x04\xbe\x01\x0b\x10\n\r\n\x05\x04\x03\x02\x07\x01\x12\x04\xbe\x01\x11\ + \x1c\n\r\n\x05\x04\x03\x02\x07\x03\x12\x04\xbe\x01\x1f\x20\n\xfa\x01\n\ + \x04\x04\x03\x02\x08\x12\x04\xc4\x01\x02!\x1a\xeb\x01\x20JSON\x20name\ + \x20of\x20this\x20field.\x20The\x20value\x20is\x20set\x20by\x20protocol\ + \x20compiler.\x20If\x20the\n\x20user\x20has\x20set\x20a\x20\"json_name\"\ + \x20option\x20on\x20this\x20field,\x20that\x20option's\x20value\n\x20wil\ + l\x20be\x20used.\x20Otherwise,\x20it's\x20deduced\x20from\x20the\x20fiel\ + d's\x20name\x20by\x20converting\n\x20it\x20to\x20camelCase.\n\n\r\n\x05\ + \x04\x03\x02\x08\x04\x12\x04\xc4\x01\x02\n\n\r\n\x05\x04\x03\x02\x08\x05\ + \x12\x04\xc4\x01\x0b\x11\n\r\n\x05\x04\x03\x02\x08\x01\x12\x04\xc4\x01\ + \x12\x1b\n\r\n\x05\x04\x03\x02\x08\x03\x12\x04\xc4\x01\x1e\x20\n\x0c\n\ + \x04\x04\x03\x02\t\x12\x04\xc6\x01\x02$\n\r\n\x05\x04\x03\x02\t\x04\x12\ + \x04\xc6\x01\x02\n\n\r\n\x05\x04\x03\x02\t\x06\x12\x04\xc6\x01\x0b\x17\n\ + \r\n\x05\x04\x03\x02\t\x01\x12\x04\xc6\x01\x18\x1f\n\r\n\x05\x04\x03\x02\ + \t\x03\x12\x04\xc6\x01\"#\n\"\n\x02\x04\x04\x12\x06\xca\x01\0\xcd\x01\ + \x01\x1a\x14\x20Describes\x20a\x20oneof.\n\n\x0b\n\x03\x04\x04\x01\x12\ + \x04\xca\x01\x08\x1c\n\x0c\n\x04\x04\x04\x02\0\x12\x04\xcb\x01\x02\x1b\n\ + \r\n\x05\x04\x04\x02\0\x04\x12\x04\xcb\x01\x02\n\n\r\n\x05\x04\x04\x02\0\ + \x05\x12\x04\xcb\x01\x0b\x11\n\r\n\x05\x04\x04\x02\0\x01\x12\x04\xcb\x01\ + \x12\x16\n\r\n\x05\x04\x04\x02\0\x03\x12\x04\xcb\x01\x19\x1a\n\x0c\n\x04\ + \x04\x04\x02\x01\x12\x04\xcc\x01\x02$\n\r\n\x05\x04\x04\x02\x01\x04\x12\ + \x04\xcc\x01\x02\n\n\r\n\x05\x04\x04\x02\x01\x06\x12\x04\xcc\x01\x0b\x17\ + \n\r\n\x05\x04\x04\x02\x01\x01\x12\x04\xcc\x01\x18\x1f\n\r\n\x05\x04\x04\ + \x02\x01\x03\x12\x04\xcc\x01\"#\n'\n\x02\x04\x05\x12\x06\xd0\x01\0\xd6\ + \x01\x01\x1a\x19\x20Describes\x20an\x20enum\x20type.\n\n\x0b\n\x03\x04\ + \x05\x01\x12\x04\xd0\x01\x08\x1b\n\x0c\n\x04\x04\x05\x02\0\x12\x04\xd1\ + \x01\x02\x1b\n\r\n\x05\x04\x05\x02\0\x04\x12\x04\xd1\x01\x02\n\n\r\n\x05\ + \x04\x05\x02\0\x05\x12\x04\xd1\x01\x0b\x11\n\r\n\x05\x04\x05\x02\0\x01\ + \x12\x04\xd1\x01\x12\x16\n\r\n\x05\x04\x05\x02\0\x03\x12\x04\xd1\x01\x19\ + \x1a\n\x0c\n\x04\x04\x05\x02\x01\x12\x04\xd3\x01\x02.\n\r\n\x05\x04\x05\ + \x02\x01\x04\x12\x04\xd3\x01\x02\n\n\r\n\x05\x04\x05\x02\x01\x06\x12\x04\ + \xd3\x01\x0b#\n\r\n\x05\x04\x05\x02\x01\x01\x12\x04\xd3\x01$)\n\r\n\x05\ + \x04\x05\x02\x01\x03\x12\x04\xd3\x01,-\n\x0c\n\x04\x04\x05\x02\x02\x12\ + \x04\xd5\x01\x02#\n\r\n\x05\x04\x05\x02\x02\x04\x12\x04\xd5\x01\x02\n\n\ + \r\n\x05\x04\x05\x02\x02\x06\x12\x04\xd5\x01\x0b\x16\n\r\n\x05\x04\x05\ + \x02\x02\x01\x12\x04\xd5\x01\x17\x1e\n\r\n\x05\x04\x05\x02\x02\x03\x12\ + \x04\xd5\x01!\"\n1\n\x02\x04\x06\x12\x06\xd9\x01\0\xde\x01\x01\x1a#\x20D\ + escribes\x20a\x20value\x20within\x20an\x20enum.\n\n\x0b\n\x03\x04\x06\ + \x01\x12\x04\xd9\x01\x08\x20\n\x0c\n\x04\x04\x06\x02\0\x12\x04\xda\x01\ + \x02\x1b\n\r\n\x05\x04\x06\x02\0\x04\x12\x04\xda\x01\x02\n\n\r\n\x05\x04\ + \x06\x02\0\x05\x12\x04\xda\x01\x0b\x11\n\r\n\x05\x04\x06\x02\0\x01\x12\ + \x04\xda\x01\x12\x16\n\r\n\x05\x04\x06\x02\0\x03\x12\x04\xda\x01\x19\x1a\ + \n\x0c\n\x04\x04\x06\x02\x01\x12\x04\xdb\x01\x02\x1c\n\r\n\x05\x04\x06\ + \x02\x01\x04\x12\x04\xdb\x01\x02\n\n\r\n\x05\x04\x06\x02\x01\x05\x12\x04\ + \xdb\x01\x0b\x10\n\r\n\x05\x04\x06\x02\x01\x01\x12\x04\xdb\x01\x11\x17\n\ + \r\n\x05\x04\x06\x02\x01\x03\x12\x04\xdb\x01\x1a\x1b\n\x0c\n\x04\x04\x06\ + \x02\x02\x12\x04\xdd\x01\x02(\n\r\n\x05\x04\x06\x02\x02\x04\x12\x04\xdd\ + \x01\x02\n\n\r\n\x05\x04\x06\x02\x02\x06\x12\x04\xdd\x01\x0b\x1b\n\r\n\ + \x05\x04\x06\x02\x02\x01\x12\x04\xdd\x01\x1c#\n\r\n\x05\x04\x06\x02\x02\ + \x03\x12\x04\xdd\x01&'\n$\n\x02\x04\x07\x12\x06\xe1\x01\0\xe6\x01\x01\ + \x1a\x16\x20Describes\x20a\x20service.\n\n\x0b\n\x03\x04\x07\x01\x12\x04\ + \xe1\x01\x08\x1e\n\x0c\n\x04\x04\x07\x02\0\x12\x04\xe2\x01\x02\x1b\n\r\n\ + \x05\x04\x07\x02\0\x04\x12\x04\xe2\x01\x02\n\n\r\n\x05\x04\x07\x02\0\x05\ + \x12\x04\xe2\x01\x0b\x11\n\r\n\x05\x04\x07\x02\0\x01\x12\x04\xe2\x01\x12\ + \x16\n\r\n\x05\x04\x07\x02\0\x03\x12\x04\xe2\x01\x19\x1a\n\x0c\n\x04\x04\ + \x07\x02\x01\x12\x04\xe3\x01\x02,\n\r\n\x05\x04\x07\x02\x01\x04\x12\x04\ + \xe3\x01\x02\n\n\r\n\x05\x04\x07\x02\x01\x06\x12\x04\xe3\x01\x0b\x20\n\r\ + \n\x05\x04\x07\x02\x01\x01\x12\x04\xe3\x01!'\n\r\n\x05\x04\x07\x02\x01\ + \x03\x12\x04\xe3\x01*+\n\x0c\n\x04\x04\x07\x02\x02\x12\x04\xe5\x01\x02&\ + \n\r\n\x05\x04\x07\x02\x02\x04\x12\x04\xe5\x01\x02\n\n\r\n\x05\x04\x07\ + \x02\x02\x06\x12\x04\xe5\x01\x0b\x19\n\r\n\x05\x04\x07\x02\x02\x01\x12\ + \x04\xe5\x01\x1a!\n\r\n\x05\x04\x07\x02\x02\x03\x12\x04\xe5\x01$%\n0\n\ + \x02\x04\x08\x12\x06\xe9\x01\0\xf7\x01\x01\x1a\"\x20Describes\x20a\x20me\ + thod\x20of\x20a\x20service.\n\n\x0b\n\x03\x04\x08\x01\x12\x04\xe9\x01\ + \x08\x1d\n\x0c\n\x04\x04\x08\x02\0\x12\x04\xea\x01\x02\x1b\n\r\n\x05\x04\ + \x08\x02\0\x04\x12\x04\xea\x01\x02\n\n\r\n\x05\x04\x08\x02\0\x05\x12\x04\ + \xea\x01\x0b\x11\n\r\n\x05\x04\x08\x02\0\x01\x12\x04\xea\x01\x12\x16\n\r\ + \n\x05\x04\x08\x02\0\x03\x12\x04\xea\x01\x19\x1a\n\x97\x01\n\x04\x04\x08\ + \x02\x01\x12\x04\xee\x01\x02!\x1a\x88\x01\x20Input\x20and\x20output\x20t\ + ype\x20names.\x20\x20These\x20are\x20resolved\x20in\x20the\x20same\x20wa\ + y\x20as\n\x20FieldDescriptorProto.type_name,\x20but\x20must\x20refer\x20\ + to\x20a\x20message\x20type.\n\n\r\n\x05\x04\x08\x02\x01\x04\x12\x04\xee\ + \x01\x02\n\n\r\n\x05\x04\x08\x02\x01\x05\x12\x04\xee\x01\x0b\x11\n\r\n\ + \x05\x04\x08\x02\x01\x01\x12\x04\xee\x01\x12\x1c\n\r\n\x05\x04\x08\x02\ + \x01\x03\x12\x04\xee\x01\x1f\x20\n\x0c\n\x04\x04\x08\x02\x02\x12\x04\xef\ + \x01\x02\"\n\r\n\x05\x04\x08\x02\x02\x04\x12\x04\xef\x01\x02\n\n\r\n\x05\ + \x04\x08\x02\x02\x05\x12\x04\xef\x01\x0b\x11\n\r\n\x05\x04\x08\x02\x02\ + \x01\x12\x04\xef\x01\x12\x1d\n\r\n\x05\x04\x08\x02\x02\x03\x12\x04\xef\ + \x01\x20!\n\x0c\n\x04\x04\x08\x02\x03\x12\x04\xf1\x01\x02%\n\r\n\x05\x04\ + \x08\x02\x03\x04\x12\x04\xf1\x01\x02\n\n\r\n\x05\x04\x08\x02\x03\x06\x12\ + \x04\xf1\x01\x0b\x18\n\r\n\x05\x04\x08\x02\x03\x01\x12\x04\xf1\x01\x19\ + \x20\n\r\n\x05\x04\x08\x02\x03\x03\x12\x04\xf1\x01#$\nE\n\x04\x04\x08\ + \x02\x04\x12\x04\xf4\x01\x025\x1a7\x20Identifies\x20if\x20client\x20stre\ + ams\x20multiple\x20client\x20messages\n\n\r\n\x05\x04\x08\x02\x04\x04\ + \x12\x04\xf4\x01\x02\n\n\r\n\x05\x04\x08\x02\x04\x05\x12\x04\xf4\x01\x0b\ + \x0f\n\r\n\x05\x04\x08\x02\x04\x01\x12\x04\xf4\x01\x10\x20\n\r\n\x05\x04\ + \x08\x02\x04\x03\x12\x04\xf4\x01#$\n\r\n\x05\x04\x08\x02\x04\x08\x12\x04\ + \xf4\x01%4\n\r\n\x05\x04\x08\x02\x04\x07\x12\x04\xf4\x01.3\nE\n\x04\x04\ + \x08\x02\x05\x12\x04\xf6\x01\x025\x1a7\x20Identifies\x20if\x20server\x20\ + streams\x20multiple\x20server\x20messages\n\n\r\n\x05\x04\x08\x02\x05\ + \x04\x12\x04\xf6\x01\x02\n\n\r\n\x05\x04\x08\x02\x05\x05\x12\x04\xf6\x01\ + \x0b\x0f\n\r\n\x05\x04\x08\x02\x05\x01\x12\x04\xf6\x01\x10\x20\n\r\n\x05\ + \x04\x08\x02\x05\x03\x12\x04\xf6\x01#$\n\r\n\x05\x04\x08\x02\x05\x08\x12\ + \x04\xf6\x01%4\n\r\n\x05\x04\x08\x02\x05\x07\x12\x04\xf6\x01.3\n\xaf\x0e\ + \n\x02\x04\t\x12\x06\x9b\x02\0\xf8\x02\x012N\x20========================\ + ===========================================\n\x20Options\n2\xd0\r\x20Eac\ + h\x20of\x20the\x20definitions\x20above\x20may\x20have\x20\"options\"\x20\ + attached.\x20\x20These\x20are\n\x20just\x20annotations\x20which\x20may\ + \x20cause\x20code\x20to\x20be\x20generated\x20slightly\x20differently\n\ + \x20or\x20may\x20contain\x20hints\x20for\x20code\x20that\x20manipulates\ + \x20protocol\x20messages.\n\n\x20Clients\x20may\x20define\x20custom\x20o\ + ptions\x20as\x20extensions\x20of\x20the\x20*Options\x20messages.\n\x20Th\ + ese\x20extensions\x20may\x20not\x20yet\x20be\x20known\x20at\x20parsing\ + \x20time,\x20so\x20the\x20parser\x20cannot\n\x20store\x20the\x20values\ + \x20in\x20them.\x20\x20Instead\x20it\x20stores\x20them\x20in\x20a\x20fie\ + ld\x20in\x20the\x20*Options\n\x20message\x20called\x20uninterpreted_opti\ + on.\x20This\x20field\x20must\x20have\x20the\x20same\x20name\n\x20across\ + \x20all\x20*Options\x20messages.\x20We\x20then\x20use\x20this\x20field\ + \x20to\x20populate\x20the\n\x20extensions\x20when\x20we\x20build\x20a\ + \x20descriptor,\x20at\x20which\x20point\x20all\x20protos\x20have\x20been\ + \n\x20parsed\x20and\x20so\x20all\x20extensions\x20are\x20known.\n\n\x20E\ + xtension\x20numbers\x20for\x20custom\x20options\x20may\x20be\x20chosen\ + \x20as\x20follows:\n\x20*\x20For\x20options\x20which\x20will\x20only\x20\ + be\x20used\x20within\x20a\x20single\x20application\x20or\n\x20\x20\x20or\ + ganization,\x20or\x20for\x20experimental\x20options,\x20use\x20field\x20\ + numbers\x2050000\n\x20\x20\x20through\x2099999.\x20\x20It\x20is\x20up\ + \x20to\x20you\x20to\x20ensure\x20that\x20you\x20do\x20not\x20use\x20the\ + \n\x20\x20\x20same\x20number\x20for\x20multiple\x20options.\n\x20*\x20Fo\ + r\x20options\x20which\x20will\x20be\x20published\x20and\x20used\x20publi\ + cly\x20by\x20multiple\n\x20\x20\x20independent\x20entities,\x20e-mail\ + \x20protobuf-global-extension-registry@google.com\n\x20\x20\x20to\x20res\ + erve\x20extension\x20numbers.\x20Simply\x20provide\x20your\x20project\ + \x20name\x20(e.g.\n\x20\x20\x20Objective-C\x20plugin)\x20and\x20your\x20\ + project\x20website\x20(if\x20available)\x20--\x20there's\x20no\n\x20\x20\ + \x20need\x20to\x20explain\x20how\x20you\x20intend\x20to\x20use\x20them.\ + \x20Usually\x20you\x20only\x20need\x20one\n\x20\x20\x20extension\x20numb\ + er.\x20You\x20can\x20declare\x20multiple\x20options\x20with\x20only\x20o\ + ne\x20extension\n\x20\x20\x20number\x20by\x20putting\x20them\x20in\x20a\ + \x20sub-message.\x20See\x20the\x20Custom\x20Options\x20section\x20of\n\ + \x20\x20\x20the\x20docs\x20for\x20examples:\n\x20\x20\x20https://develop\ + ers.google.com/protocol-buffers/docs/proto#options\n\x20\x20\x20If\x20th\ + is\x20turns\x20out\x20to\x20be\x20popular,\x20a\x20web\x20service\x20wil\ + l\x20be\x20set\x20up\n\x20\x20\x20to\x20automatically\x20assign\x20optio\ + n\x20numbers.\n\n\x0b\n\x03\x04\t\x01\x12\x04\x9b\x02\x08\x13\n\xf4\x01\ + \n\x04\x04\t\x02\0\x12\x04\xa1\x02\x02#\x1a\xe5\x01\x20Sets\x20the\x20Ja\ + va\x20package\x20where\x20classes\x20generated\x20from\x20this\x20.proto\ + \x20will\x20be\n\x20placed.\x20\x20By\x20default,\x20the\x20proto\x20pac\ + kage\x20is\x20used,\x20but\x20this\x20is\x20often\n\x20inappropriate\x20\ + because\x20proto\x20packages\x20do\x20not\x20normally\x20start\x20with\ + \x20backwards\n\x20domain\x20names.\n\n\r\n\x05\x04\t\x02\0\x04\x12\x04\ + \xa1\x02\x02\n\n\r\n\x05\x04\t\x02\0\x05\x12\x04\xa1\x02\x0b\x11\n\r\n\ + \x05\x04\t\x02\0\x01\x12\x04\xa1\x02\x12\x1e\n\r\n\x05\x04\t\x02\0\x03\ + \x12\x04\xa1\x02!\"\n\xbf\x02\n\x04\x04\t\x02\x01\x12\x04\xa9\x02\x02+\ + \x1a\xb0\x02\x20If\x20set,\x20all\x20the\x20classes\x20from\x20the\x20.p\ + roto\x20file\x20are\x20wrapped\x20in\x20a\x20single\n\x20outer\x20class\ + \x20with\x20the\x20given\x20name.\x20\x20This\x20applies\x20to\x20both\ + \x20Proto1\n\x20(equivalent\x20to\x20the\x20old\x20\"--one_java_file\"\ + \x20option)\x20and\x20Proto2\x20(where\n\x20a\x20.proto\x20always\x20tra\ + nslates\x20to\x20a\x20single\x20class,\x20but\x20you\x20may\x20want\x20t\ + o\n\x20explicitly\x20choose\x20the\x20class\x20name).\n\n\r\n\x05\x04\t\ + \x02\x01\x04\x12\x04\xa9\x02\x02\n\n\r\n\x05\x04\t\x02\x01\x05\x12\x04\ + \xa9\x02\x0b\x11\n\r\n\x05\x04\t\x02\x01\x01\x12\x04\xa9\x02\x12&\n\r\n\ + \x05\x04\t\x02\x01\x03\x12\x04\xa9\x02)*\n\xa3\x03\n\x04\x04\t\x02\x02\ + \x12\x04\xb1\x02\x029\x1a\x94\x03\x20If\x20set\x20true,\x20then\x20the\ + \x20Java\x20code\x20generator\x20will\x20generate\x20a\x20separate\x20.j\ + ava\n\x20file\x20for\x20each\x20top-level\x20message,\x20enum,\x20and\ + \x20service\x20defined\x20in\x20the\x20.proto\n\x20file.\x20\x20Thus,\ + \x20these\x20types\x20will\x20*not*\x20be\x20nested\x20inside\x20the\x20\ + outer\x20class\n\x20named\x20by\x20java_outer_classname.\x20\x20However,\ + \x20the\x20outer\x20class\x20will\x20still\x20be\n\x20generated\x20to\ + \x20contain\x20the\x20file's\x20getDescriptor()\x20method\x20as\x20well\ + \x20as\x20any\n\x20top-level\x20extensions\x20defined\x20in\x20the\x20fi\ + le.\n\n\r\n\x05\x04\t\x02\x02\x04\x12\x04\xb1\x02\x02\n\n\r\n\x05\x04\t\ + \x02\x02\x05\x12\x04\xb1\x02\x0b\x0f\n\r\n\x05\x04\t\x02\x02\x01\x12\x04\ + \xb1\x02\x10#\n\r\n\x05\x04\t\x02\x02\x03\x12\x04\xb1\x02&(\n\r\n\x05\ + \x04\t\x02\x02\x08\x12\x04\xb1\x02)8\n\r\n\x05\x04\t\x02\x02\x07\x12\x04\ + \xb1\x0227\n)\n\x04\x04\t\x02\x03\x12\x04\xb4\x02\x02E\x1a\x1b\x20This\ + \x20option\x20does\x20nothing.\n\n\r\n\x05\x04\t\x02\x03\x04\x12\x04\xb4\ + \x02\x02\n\n\r\n\x05\x04\t\x02\x03\x05\x12\x04\xb4\x02\x0b\x0f\n\r\n\x05\ + \x04\t\x02\x03\x01\x12\x04\xb4\x02\x10-\n\r\n\x05\x04\t\x02\x03\x03\x12\ + \x04\xb4\x0202\n\r\n\x05\x04\t\x02\x03\x08\x12\x04\xb4\x023D\n\x10\n\x08\ + \x04\t\x02\x03\x08\xe7\x07\0\x12\x04\xb4\x024C\n\x11\n\t\x04\t\x02\x03\ + \x08\xe7\x07\0\x02\x12\x04\xb4\x024>\n\x12\n\n\x04\t\x02\x03\x08\xe7\x07\ + \0\x02\0\x12\x04\xb4\x024>\n\x13\n\x0b\x04\t\x02\x03\x08\xe7\x07\0\x02\0\ + \x01\x12\x04\xb4\x024>\n\x11\n\t\x04\t\x02\x03\x08\xe7\x07\0\x03\x12\x04\ + \xb4\x02?C\n\xe6\x02\n\x04\x04\t\x02\x04\x12\x04\xbc\x02\x02<\x1a\xd7\ + \x02\x20If\x20set\x20true,\x20then\x20the\x20Java2\x20code\x20generator\ + \x20will\x20generate\x20code\x20that\n\x20throws\x20an\x20exception\x20w\ + henever\x20an\x20attempt\x20is\x20made\x20to\x20assign\x20a\x20non-UTF-8\ + \n\x20byte\x20sequence\x20to\x20a\x20string\x20field.\n\x20Message\x20re\ + flection\x20will\x20do\x20the\x20same.\n\x20However,\x20an\x20extension\ + \x20field\x20still\x20accepts\x20non-UTF-8\x20byte\x20sequences.\n\x20Th\ + is\x20option\x20has\x20no\x20effect\x20on\x20when\x20used\x20with\x20the\ + \x20lite\x20runtime.\n\n\r\n\x05\x04\t\x02\x04\x04\x12\x04\xbc\x02\x02\n\ + \n\r\n\x05\x04\t\x02\x04\x05\x12\x04\xbc\x02\x0b\x0f\n\r\n\x05\x04\t\x02\ + \x04\x01\x12\x04\xbc\x02\x10&\n\r\n\x05\x04\t\x02\x04\x03\x12\x04\xbc\ + \x02)+\n\r\n\x05\x04\t\x02\x04\x08\x12\x04\xbc\x02,;\n\r\n\x05\x04\t\x02\ + \x04\x07\x12\x04\xbc\x025:\nL\n\x04\x04\t\x04\0\x12\x06\xc0\x02\x02\xc5\ + \x02\x03\x1a<\x20Generated\x20classes\x20can\x20be\x20optimized\x20for\ + \x20speed\x20or\x20code\x20size.\n\n\r\n\x05\x04\t\x04\0\x01\x12\x04\xc0\ + \x02\x07\x13\nD\n\x06\x04\t\x04\0\x02\0\x12\x04\xc1\x02\x04\x0e\"4\x20Ge\ + nerate\x20complete\x20code\x20for\x20parsing,\x20serialization,\n\n\x0f\ + \n\x07\x04\t\x04\0\x02\0\x01\x12\x04\xc1\x02\x04\t\n\x0f\n\x07\x04\t\x04\ + \0\x02\0\x02\x12\x04\xc1\x02\x0c\r\nG\n\x06\x04\t\x04\0\x02\x01\x12\x04\ + \xc3\x02\x04\x12\x1a\x06\x20etc.\n\"/\x20Use\x20ReflectionOps\x20to\x20i\ + mplement\x20these\x20methods.\n\n\x0f\n\x07\x04\t\x04\0\x02\x01\x01\x12\ + \x04\xc3\x02\x04\r\n\x0f\n\x07\x04\t\x04\0\x02\x01\x02\x12\x04\xc3\x02\ + \x10\x11\nG\n\x06\x04\t\x04\0\x02\x02\x12\x04\xc4\x02\x04\x15\"7\x20Gene\ + rate\x20code\x20using\x20MessageLite\x20and\x20the\x20lite\x20runtime.\n\ + \n\x0f\n\x07\x04\t\x04\0\x02\x02\x01\x12\x04\xc4\x02\x04\x10\n\x0f\n\x07\ + \x04\t\x04\0\x02\x02\x02\x12\x04\xc4\x02\x13\x14\n\x0c\n\x04\x04\t\x02\ + \x05\x12\x04\xc6\x02\x029\n\r\n\x05\x04\t\x02\x05\x04\x12\x04\xc6\x02\ + \x02\n\n\r\n\x05\x04\t\x02\x05\x06\x12\x04\xc6\x02\x0b\x17\n\r\n\x05\x04\ + \t\x02\x05\x01\x12\x04\xc6\x02\x18$\n\r\n\x05\x04\t\x02\x05\x03\x12\x04\ + \xc6\x02'(\n\r\n\x05\x04\t\x02\x05\x08\x12\x04\xc6\x02)8\n\r\n\x05\x04\t\ + \x02\x05\x07\x12\x04\xc6\x0227\n\xe2\x02\n\x04\x04\t\x02\x06\x12\x04\xcd\ + \x02\x02\"\x1a\xd3\x02\x20Sets\x20the\x20Go\x20package\x20where\x20struc\ + ts\x20generated\x20from\x20this\x20.proto\x20will\x20be\n\x20placed.\x20\ + If\x20omitted,\x20the\x20Go\x20package\x20will\x20be\x20derived\x20from\ + \x20the\x20following:\n\x20\x20\x20-\x20The\x20basename\x20of\x20the\x20\ + package\x20import\x20path,\x20if\x20provided.\n\x20\x20\x20-\x20Otherwis\ + e,\x20the\x20package\x20statement\x20in\x20the\x20.proto\x20file,\x20if\ + \x20present.\n\x20\x20\x20-\x20Otherwise,\x20the\x20basename\x20of\x20th\ + e\x20.proto\x20file,\x20without\x20extension.\n\n\r\n\x05\x04\t\x02\x06\ + \x04\x12\x04\xcd\x02\x02\n\n\r\n\x05\x04\t\x02\x06\x05\x12\x04\xcd\x02\ + \x0b\x11\n\r\n\x05\x04\t\x02\x06\x01\x12\x04\xcd\x02\x12\x1c\n\r\n\x05\ + \x04\t\x02\x06\x03\x12\x04\xcd\x02\x1f!\n\xd4\x04\n\x04\x04\t\x02\x07\ + \x12\x04\xdb\x02\x029\x1a\xc5\x04\x20Should\x20generic\x20services\x20be\ + \x20generated\x20in\x20each\x20language?\x20\x20\"Generic\"\x20services\ + \n\x20are\x20not\x20specific\x20to\x20any\x20particular\x20RPC\x20system\ + .\x20\x20They\x20are\x20generated\x20by\x20the\n\x20main\x20code\x20gene\ + rators\x20in\x20each\x20language\x20(without\x20additional\x20plugins).\ + \n\x20Generic\x20services\x20were\x20the\x20only\x20kind\x20of\x20servic\ + e\x20generation\x20supported\x20by\n\x20early\x20versions\x20of\x20googl\ + e.protobuf.\n\n\x20Generic\x20services\x20are\x20now\x20considered\x20de\ + precated\x20in\x20favor\x20of\x20using\x20plugins\n\x20that\x20generate\ + \x20code\x20specific\x20to\x20your\x20particular\x20RPC\x20system.\x20\ + \x20Therefore,\n\x20these\x20default\x20to\x20false.\x20\x20Old\x20code\ + \x20which\x20depends\x20on\x20generic\x20services\x20should\n\x20explici\ + tly\x20set\x20them\x20to\x20true.\n\n\r\n\x05\x04\t\x02\x07\x04\x12\x04\ + \xdb\x02\x02\n\n\r\n\x05\x04\t\x02\x07\x05\x12\x04\xdb\x02\x0b\x0f\n\r\n\ + \x05\x04\t\x02\x07\x01\x12\x04\xdb\x02\x10#\n\r\n\x05\x04\t\x02\x07\x03\ + \x12\x04\xdb\x02&(\n\r\n\x05\x04\t\x02\x07\x08\x12\x04\xdb\x02)8\n\r\n\ + \x05\x04\t\x02\x07\x07\x12\x04\xdb\x0227\n\x0c\n\x04\x04\t\x02\x08\x12\ + \x04\xdc\x02\x02;\n\r\n\x05\x04\t\x02\x08\x04\x12\x04\xdc\x02\x02\n\n\r\ + \n\x05\x04\t\x02\x08\x05\x12\x04\xdc\x02\x0b\x0f\n\r\n\x05\x04\t\x02\x08\ + \x01\x12\x04\xdc\x02\x10%\n\r\n\x05\x04\t\x02\x08\x03\x12\x04\xdc\x02(*\ + \n\r\n\x05\x04\t\x02\x08\x08\x12\x04\xdc\x02+:\n\r\n\x05\x04\t\x02\x08\ + \x07\x12\x04\xdc\x0249\n\x0c\n\x04\x04\t\x02\t\x12\x04\xdd\x02\x029\n\r\ + \n\x05\x04\t\x02\t\x04\x12\x04\xdd\x02\x02\n\n\r\n\x05\x04\t\x02\t\x05\ + \x12\x04\xdd\x02\x0b\x0f\n\r\n\x05\x04\t\x02\t\x01\x12\x04\xdd\x02\x10#\ + \n\r\n\x05\x04\t\x02\t\x03\x12\x04\xdd\x02&(\n\r\n\x05\x04\t\x02\t\x08\ + \x12\x04\xdd\x02)8\n\r\n\x05\x04\t\x02\t\x07\x12\x04\xdd\x0227\n\xf3\x01\ + \n\x04\x04\t\x02\n\x12\x04\xe3\x02\x020\x1a\xe4\x01\x20Is\x20this\x20fil\ + e\x20deprecated?\n\x20Depending\x20on\x20the\x20target\x20platform,\x20t\ + his\x20can\x20emit\x20Deprecated\x20annotations\n\x20for\x20everything\ + \x20in\x20the\x20file,\x20or\x20it\x20will\x20be\x20completely\x20ignore\ + d;\x20in\x20the\x20very\n\x20least,\x20this\x20is\x20a\x20formalization\ + \x20for\x20deprecating\x20files.\n\n\r\n\x05\x04\t\x02\n\x04\x12\x04\xe3\ + \x02\x02\n\n\r\n\x05\x04\t\x02\n\x05\x12\x04\xe3\x02\x0b\x0f\n\r\n\x05\ + \x04\t\x02\n\x01\x12\x04\xe3\x02\x10\x1a\n\r\n\x05\x04\t\x02\n\x03\x12\ + \x04\xe3\x02\x1d\x1f\n\r\n\x05\x04\t\x02\n\x08\x12\x04\xe3\x02\x20/\n\r\ + \n\x05\x04\t\x02\n\x07\x12\x04\xe3\x02).\n\x7f\n\x04\x04\t\x02\x0b\x12\ + \x04\xe7\x02\x026\x1aq\x20Enables\x20the\x20use\x20of\x20arenas\x20for\ + \x20the\x20proto\x20messages\x20in\x20this\x20file.\x20This\x20applies\n\ + \x20only\x20to\x20generated\x20classes\x20for\x20C++.\n\n\r\n\x05\x04\t\ + \x02\x0b\x04\x12\x04\xe7\x02\x02\n\n\r\n\x05\x04\t\x02\x0b\x05\x12\x04\ + \xe7\x02\x0b\x0f\n\r\n\x05\x04\t\x02\x0b\x01\x12\x04\xe7\x02\x10\x20\n\r\ + \n\x05\x04\t\x02\x0b\x03\x12\x04\xe7\x02#%\n\r\n\x05\x04\t\x02\x0b\x08\ + \x12\x04\xe7\x02&5\n\r\n\x05\x04\t\x02\x0b\x07\x12\x04\xe7\x02/4\n\x92\ + \x01\n\x04\x04\t\x02\x0c\x12\x04\xec\x02\x02)\x1a\x83\x01\x20Sets\x20the\ + \x20objective\x20c\x20class\x20prefix\x20which\x20is\x20prepended\x20to\ + \x20all\x20objective\x20c\n\x20generated\x20classes\x20from\x20this\x20.\ + proto.\x20There\x20is\x20no\x20default.\n\n\r\n\x05\x04\t\x02\x0c\x04\ + \x12\x04\xec\x02\x02\n\n\r\n\x05\x04\t\x02\x0c\x05\x12\x04\xec\x02\x0b\ + \x11\n\r\n\x05\x04\t\x02\x0c\x01\x12\x04\xec\x02\x12#\n\r\n\x05\x04\t\ + \x02\x0c\x03\x12\x04\xec\x02&(\nI\n\x04\x04\t\x02\r\x12\x04\xef\x02\x02(\ + \x1a;\x20Namespace\x20for\x20generated\x20classes;\x20defaults\x20to\x20\ + the\x20package.\n\n\r\n\x05\x04\t\x02\r\x04\x12\x04\xef\x02\x02\n\n\r\n\ + \x05\x04\t\x02\r\x05\x12\x04\xef\x02\x0b\x11\n\r\n\x05\x04\t\x02\r\x01\ + \x12\x04\xef\x02\x12\"\n\r\n\x05\x04\t\x02\r\x03\x12\x04\xef\x02%'\nO\n\ + \x04\x04\t\x02\x0e\x12\x04\xf2\x02\x02:\x1aA\x20The\x20parser\x20stores\ + \x20options\x20it\x20doesn't\x20recognize\x20here.\x20See\x20above.\n\n\ + \r\n\x05\x04\t\x02\x0e\x04\x12\x04\xf2\x02\x02\n\n\r\n\x05\x04\t\x02\x0e\ + \x06\x12\x04\xf2\x02\x0b\x1e\n\r\n\x05\x04\t\x02\x0e\x01\x12\x04\xf2\x02\ + \x1f3\n\r\n\x05\x04\t\x02\x0e\x03\x12\x04\xf2\x0269\nZ\n\x03\x04\t\x05\ + \x12\x04\xf5\x02\x02\x19\x1aM\x20Clients\x20can\x20define\x20custom\x20o\ + ptions\x20in\x20extensions\x20of\x20this\x20message.\x20See\x20above.\n\ + \n\x0c\n\x04\x04\t\x05\0\x12\x04\xf5\x02\r\x18\n\r\n\x05\x04\t\x05\0\x01\ + \x12\x04\xf5\x02\r\x11\n\r\n\x05\x04\t\x05\0\x02\x12\x04\xf5\x02\x15\x18\ + \n\x0c\n\x02\x04\n\x12\x06\xfa\x02\0\xb8\x03\x01\n\x0b\n\x03\x04\n\x01\ + \x12\x04\xfa\x02\x08\x16\n\xd8\x05\n\x04\x04\n\x02\0\x12\x04\x8d\x03\x02\ + <\x1a\xc9\x05\x20Set\x20true\x20to\x20use\x20the\x20old\x20proto1\x20Mes\ + sageSet\x20wire\x20format\x20for\x20extensions.\n\x20This\x20is\x20provi\ + ded\x20for\x20backwards-compatibility\x20with\x20the\x20MessageSet\x20wi\ + re\n\x20format.\x20\x20You\x20should\x20not\x20use\x20this\x20for\x20any\ + \x20other\x20reason:\x20\x20It's\x20less\n\x20efficient,\x20has\x20fewer\ + \x20features,\x20and\x20is\x20more\x20complicated.\n\n\x20The\x20message\ + \x20must\x20be\x20defined\x20exactly\x20as\x20follows:\n\x20\x20\x20mess\ + age\x20Foo\x20{\n\x20\x20\x20\x20\x20option\x20message_set_wire_format\ + \x20=\x20true;\n\x20\x20\x20\x20\x20extensions\x204\x20to\x20max;\n\x20\ + \x20\x20}\n\x20Note\x20that\x20the\x20message\x20cannot\x20have\x20any\ + \x20defined\x20fields;\x20MessageSets\x20only\n\x20have\x20extensions.\n\ + \n\x20All\x20extensions\x20of\x20your\x20type\x20must\x20be\x20singular\ + \x20messages;\x20e.g.\x20they\x20cannot\n\x20be\x20int32s,\x20enums,\x20\ + or\x20repeated\x20messages.\n\n\x20Because\x20this\x20is\x20an\x20option\ + ,\x20the\x20above\x20two\x20restrictions\x20are\x20not\x20enforced\x20by\ + \n\x20the\x20protocol\x20compiler.\n\n\r\n\x05\x04\n\x02\0\x04\x12\x04\ + \x8d\x03\x02\n\n\r\n\x05\x04\n\x02\0\x05\x12\x04\x8d\x03\x0b\x0f\n\r\n\ + \x05\x04\n\x02\0\x01\x12\x04\x8d\x03\x10'\n\r\n\x05\x04\n\x02\0\x03\x12\ + \x04\x8d\x03*+\n\r\n\x05\x04\n\x02\0\x08\x12\x04\x8d\x03,;\n\r\n\x05\x04\ + \n\x02\0\x07\x12\x04\x8d\x035:\n\xeb\x01\n\x04\x04\n\x02\x01\x12\x04\x92\ + \x03\x02D\x1a\xdc\x01\x20Disables\x20the\x20generation\x20of\x20the\x20s\ + tandard\x20\"descriptor()\"\x20accessor,\x20which\x20can\n\x20conflict\ + \x20with\x20a\x20field\x20of\x20the\x20same\x20name.\x20\x20This\x20is\ + \x20meant\x20to\x20make\x20migration\n\x20from\x20proto1\x20easier;\x20n\ + ew\x20code\x20should\x20avoid\x20fields\x20named\x20\"descriptor\".\n\n\ + \r\n\x05\x04\n\x02\x01\x04\x12\x04\x92\x03\x02\n\n\r\n\x05\x04\n\x02\x01\ + \x05\x12\x04\x92\x03\x0b\x0f\n\r\n\x05\x04\n\x02\x01\x01\x12\x04\x92\x03\ + \x10/\n\r\n\x05\x04\n\x02\x01\x03\x12\x04\x92\x0323\n\r\n\x05\x04\n\x02\ + \x01\x08\x12\x04\x92\x034C\n\r\n\x05\x04\n\x02\x01\x07\x12\x04\x92\x03=B\ + \n\xee\x01\n\x04\x04\n\x02\x02\x12\x04\x98\x03\x02/\x1a\xdf\x01\x20Is\ + \x20this\x20message\x20deprecated?\n\x20Depending\x20on\x20the\x20target\ + \x20platform,\x20this\x20can\x20emit\x20Deprecated\x20annotations\n\x20f\ + or\x20the\x20message,\x20or\x20it\x20will\x20be\x20completely\x20ignored\ + ;\x20in\x20the\x20very\x20least,\n\x20this\x20is\x20a\x20formalization\ + \x20for\x20deprecating\x20messages.\n\n\r\n\x05\x04\n\x02\x02\x04\x12\ + \x04\x98\x03\x02\n\n\r\n\x05\x04\n\x02\x02\x05\x12\x04\x98\x03\x0b\x0f\n\ + \r\n\x05\x04\n\x02\x02\x01\x12\x04\x98\x03\x10\x1a\n\r\n\x05\x04\n\x02\ + \x02\x03\x12\x04\x98\x03\x1d\x1e\n\r\n\x05\x04\n\x02\x02\x08\x12\x04\x98\ + \x03\x1f.\n\r\n\x05\x04\n\x02\x02\x07\x12\x04\x98\x03(-\n\x9e\x06\n\x04\ + \x04\n\x02\x03\x12\x04\xaf\x03\x02\x1e\x1a\x8f\x06\x20Whether\x20the\x20\ + message\x20is\x20an\x20automatically\x20generated\x20map\x20entry\x20typ\ + e\x20for\x20the\n\x20maps\x20field.\n\n\x20For\x20maps\x20fields:\n\x20\ + \x20\x20\x20\x20map\x20map_field\x20=\x201;\n\x20\ + The\x20parsed\x20descriptor\x20looks\x20like:\n\x20\x20\x20\x20\x20messa\ + ge\x20MapFieldEntry\x20{\n\x20\x20\x20\x20\x20\x20\x20\x20\x20option\x20\ + map_entry\x20=\x20true;\n\x20\x20\x20\x20\x20\x20\x20\x20\x20optional\ + \x20KeyType\x20key\x20=\x201;\n\x20\x20\x20\x20\x20\x20\x20\x20\x20optio\ + nal\x20ValueType\x20value\x20=\x202;\n\x20\x20\x20\x20\x20}\n\x20\x20\ + \x20\x20\x20repeated\x20MapFieldEntry\x20map_field\x20=\x201;\n\n\x20Imp\ + lementations\x20may\x20choose\x20not\x20to\x20generate\x20the\x20map_ent\ + ry=true\x20message,\x20but\n\x20use\x20a\x20native\x20map\x20in\x20the\ + \x20target\x20language\x20to\x20hold\x20the\x20keys\x20and\x20values.\n\ + \x20The\x20reflection\x20APIs\x20in\x20such\x20implementions\x20still\ + \x20need\x20to\x20work\x20as\n\x20if\x20the\x20field\x20is\x20a\x20repea\ + ted\x20message\x20field.\n\n\x20NOTE:\x20Do\x20not\x20set\x20the\x20opti\ + on\x20in\x20.proto\x20files.\x20Always\x20use\x20the\x20maps\x20syntax\n\ + \x20instead.\x20The\x20option\x20should\x20only\x20be\x20implicitly\x20s\ + et\x20by\x20the\x20proto\x20compiler\n\x20parser.\n\n\r\n\x05\x04\n\x02\ + \x03\x04\x12\x04\xaf\x03\x02\n\n\r\n\x05\x04\n\x02\x03\x05\x12\x04\xaf\ + \x03\x0b\x0f\n\r\n\x05\x04\n\x02\x03\x01\x12\x04\xaf\x03\x10\x19\n\r\n\ + \x05\x04\n\x02\x03\x03\x12\x04\xaf\x03\x1c\x1d\nO\n\x04\x04\n\x02\x04\ + \x12\x04\xb2\x03\x02:\x1aA\x20The\x20parser\x20stores\x20options\x20it\ + \x20doesn't\x20recognize\x20here.\x20See\x20above.\n\n\r\n\x05\x04\n\x02\ + \x04\x04\x12\x04\xb2\x03\x02\n\n\r\n\x05\x04\n\x02\x04\x06\x12\x04\xb2\ + \x03\x0b\x1e\n\r\n\x05\x04\n\x02\x04\x01\x12\x04\xb2\x03\x1f3\n\r\n\x05\ + \x04\n\x02\x04\x03\x12\x04\xb2\x0369\nZ\n\x03\x04\n\x05\x12\x04\xb5\x03\ + \x02\x19\x1aM\x20Clients\x20can\x20define\x20custom\x20options\x20in\x20\ + extensions\x20of\x20this\x20message.\x20See\x20above.\n\n\x0c\n\x04\x04\ + \n\x05\0\x12\x04\xb5\x03\r\x18\n\r\n\x05\x04\n\x05\0\x01\x12\x04\xb5\x03\ + \r\x11\n\r\n\x05\x04\n\x05\0\x02\x12\x04\xb5\x03\x15\x18\n\x0c\n\x02\x04\ + \x0b\x12\x06\xba\x03\0\x93\x04\x01\n\x0b\n\x03\x04\x0b\x01\x12\x04\xba\ + \x03\x08\x14\n\xa3\x02\n\x04\x04\x0b\x02\0\x12\x04\xbf\x03\x02.\x1a\x94\ + \x02\x20The\x20ctype\x20option\x20instructs\x20the\x20C++\x20code\x20gen\ + erator\x20to\x20use\x20a\x20different\n\x20representation\x20of\x20the\ + \x20field\x20than\x20it\x20normally\x20would.\x20\x20See\x20the\x20speci\ + fic\n\x20options\x20below.\x20\x20This\x20option\x20is\x20not\x20yet\x20\ + implemented\x20in\x20the\x20open\x20source\n\x20release\x20--\x20sorry,\ + \x20we'll\x20try\x20to\x20include\x20it\x20in\x20a\x20future\x20version!\ + \n\n\r\n\x05\x04\x0b\x02\0\x04\x12\x04\xbf\x03\x02\n\n\r\n\x05\x04\x0b\ + \x02\0\x06\x12\x04\xbf\x03\x0b\x10\n\r\n\x05\x04\x0b\x02\0\x01\x12\x04\ + \xbf\x03\x11\x16\n\r\n\x05\x04\x0b\x02\0\x03\x12\x04\xbf\x03\x19\x1a\n\r\ + \n\x05\x04\x0b\x02\0\x08\x12\x04\xbf\x03\x1b-\n\r\n\x05\x04\x0b\x02\0\ + \x07\x12\x04\xbf\x03&,\n\x0e\n\x04\x04\x0b\x04\0\x12\x06\xc0\x03\x02\xc7\ + \x03\x03\n\r\n\x05\x04\x0b\x04\0\x01\x12\x04\xc0\x03\x07\x0c\n\x1f\n\x06\ + \x04\x0b\x04\0\x02\0\x12\x04\xc2\x03\x04\x0f\x1a\x0f\x20Default\x20mode.\ + \n\n\x0f\n\x07\x04\x0b\x04\0\x02\0\x01\x12\x04\xc2\x03\x04\n\n\x0f\n\x07\ + \x04\x0b\x04\0\x02\0\x02\x12\x04\xc2\x03\r\x0e\n\x0e\n\x06\x04\x0b\x04\0\ + \x02\x01\x12\x04\xc4\x03\x04\r\n\x0f\n\x07\x04\x0b\x04\0\x02\x01\x01\x12\ + \x04\xc4\x03\x04\x08\n\x0f\n\x07\x04\x0b\x04\0\x02\x01\x02\x12\x04\xc4\ + \x03\x0b\x0c\n\x0e\n\x06\x04\x0b\x04\0\x02\x02\x12\x04\xc6\x03\x04\x15\n\ + \x0f\n\x07\x04\x0b\x04\0\x02\x02\x01\x12\x04\xc6\x03\x04\x10\n\x0f\n\x07\ + \x04\x0b\x04\0\x02\x02\x02\x12\x04\xc6\x03\x13\x14\n\xda\x02\n\x04\x04\ + \x0b\x02\x01\x12\x04\xcd\x03\x02\x1b\x1a\xcb\x02\x20The\x20packed\x20opt\ + ion\x20can\x20be\x20enabled\x20for\x20repeated\x20primitive\x20fields\ + \x20to\x20enable\n\x20a\x20more\x20efficient\x20representation\x20on\x20\ + the\x20wire.\x20Rather\x20than\x20repeatedly\n\x20writing\x20the\x20tag\ + \x20and\x20type\x20for\x20each\x20element,\x20the\x20entire\x20array\x20\ + is\x20encoded\x20as\n\x20a\x20single\x20length-delimited\x20blob.\x20In\ + \x20proto3,\x20only\x20explicit\x20setting\x20it\x20to\n\x20false\x20wil\ + l\x20avoid\x20using\x20packed\x20encoding.\n\n\r\n\x05\x04\x0b\x02\x01\ + \x04\x12\x04\xcd\x03\x02\n\n\r\n\x05\x04\x0b\x02\x01\x05\x12\x04\xcd\x03\ + \x0b\x0f\n\r\n\x05\x04\x0b\x02\x01\x01\x12\x04\xcd\x03\x10\x16\n\r\n\x05\ + \x04\x0b\x02\x01\x03\x12\x04\xcd\x03\x19\x1a\n\xe4\x04\n\x04\x04\x0b\x02\ + \x02\x12\x04\xd8\x03\x023\x1a\xd5\x04\x20The\x20jstype\x20option\x20dete\ + rmines\x20the\x20JavaScript\x20type\x20used\x20for\x20values\x20of\x20th\ + e\n\x20field.\x20\x20The\x20option\x20is\x20permitted\x20only\x20for\x20\ + 64\x20bit\x20integral\x20and\x20fixed\x20types\n\x20(int64,\x20uint64,\ + \x20sint64,\x20fixed64,\x20sfixed64).\x20\x20By\x20default\x20these\x20t\ + ypes\x20are\n\x20represented\x20as\x20JavaScript\x20strings.\x20\x20This\ + \x20avoids\x20loss\x20of\x20precision\x20that\x20can\n\x20happen\x20when\ + \x20a\x20large\x20value\x20is\x20converted\x20to\x20a\x20floating\x20poi\ + nt\x20JavaScript\n\x20numbers.\x20\x20Specifying\x20JS_NUMBER\x20for\x20\ + the\x20jstype\x20causes\x20the\x20generated\n\x20JavaScript\x20code\x20t\ + o\x20use\x20the\x20JavaScript\x20\"number\"\x20type\x20instead\x20of\x20\ + strings.\n\x20This\x20option\x20is\x20an\x20enum\x20to\x20permit\x20addi\ + tional\x20types\x20to\x20be\x20added,\n\x20e.g.\x20goog.math.Integer.\n\ + \n\r\n\x05\x04\x0b\x02\x02\x04\x12\x04\xd8\x03\x02\n\n\r\n\x05\x04\x0b\ + \x02\x02\x06\x12\x04\xd8\x03\x0b\x11\n\r\n\x05\x04\x0b\x02\x02\x01\x12\ + \x04\xd8\x03\x12\x18\n\r\n\x05\x04\x0b\x02\x02\x03\x12\x04\xd8\x03\x1b\ + \x1c\n\r\n\x05\x04\x0b\x02\x02\x08\x12\x04\xd8\x03\x1d2\n\r\n\x05\x04\ + \x0b\x02\x02\x07\x12\x04\xd8\x03(1\n\x0e\n\x04\x04\x0b\x04\x01\x12\x06\ + \xd9\x03\x02\xe2\x03\x03\n\r\n\x05\x04\x0b\x04\x01\x01\x12\x04\xd9\x03\ + \x07\r\n'\n\x06\x04\x0b\x04\x01\x02\0\x12\x04\xdb\x03\x04\x12\x1a\x17\ + \x20Use\x20the\x20default\x20type.\n\n\x0f\n\x07\x04\x0b\x04\x01\x02\0\ + \x01\x12\x04\xdb\x03\x04\r\n\x0f\n\x07\x04\x0b\x04\x01\x02\0\x02\x12\x04\ + \xdb\x03\x10\x11\n)\n\x06\x04\x0b\x04\x01\x02\x01\x12\x04\xde\x03\x04\ + \x12\x1a\x19\x20Use\x20JavaScript\x20strings.\n\n\x0f\n\x07\x04\x0b\x04\ + \x01\x02\x01\x01\x12\x04\xde\x03\x04\r\n\x0f\n\x07\x04\x0b\x04\x01\x02\ + \x01\x02\x12\x04\xde\x03\x10\x11\n)\n\x06\x04\x0b\x04\x01\x02\x02\x12\ + \x04\xe1\x03\x04\x12\x1a\x19\x20Use\x20JavaScript\x20numbers.\n\n\x0f\n\ + \x07\x04\x0b\x04\x01\x02\x02\x01\x12\x04\xe1\x03\x04\r\n\x0f\n\x07\x04\ + \x0b\x04\x01\x02\x02\x02\x12\x04\xe1\x03\x10\x11\n\xef\x0c\n\x04\x04\x0b\ + \x02\x03\x12\x04\x80\x04\x02)\x1a\xe0\x0c\x20Should\x20this\x20field\x20\ + be\x20parsed\x20lazily?\x20\x20Lazy\x20applies\x20only\x20to\x20message-\ + type\n\x20fields.\x20\x20It\x20means\x20that\x20when\x20the\x20outer\x20\ + message\x20is\x20initially\x20parsed,\x20the\n\x20inner\x20message's\x20\ + contents\x20will\x20not\x20be\x20parsed\x20but\x20instead\x20stored\x20i\ + n\x20encoded\n\x20form.\x20\x20The\x20inner\x20message\x20will\x20actual\ + ly\x20be\x20parsed\x20when\x20it\x20is\x20first\x20accessed.\n\n\x20This\ + \x20is\x20only\x20a\x20hint.\x20\x20Implementations\x20are\x20free\x20to\ + \x20choose\x20whether\x20to\x20use\n\x20eager\x20or\x20lazy\x20parsing\ + \x20regardless\x20of\x20the\x20value\x20of\x20this\x20option.\x20\x20How\ + ever,\n\x20setting\x20this\x20option\x20true\x20suggests\x20that\x20the\ + \x20protocol\x20author\x20believes\x20that\n\x20using\x20lazy\x20parsing\ + \x20on\x20this\x20field\x20is\x20worth\x20the\x20additional\x20bookkeepi\ + ng\n\x20overhead\x20typically\x20needed\x20to\x20implement\x20it.\n\n\ + \x20This\x20option\x20does\x20not\x20affect\x20the\x20public\x20interfac\ + e\x20of\x20any\x20generated\x20code;\n\x20all\x20method\x20signatures\ + \x20remain\x20the\x20same.\x20\x20Furthermore,\x20thread-safety\x20of\ + \x20the\n\x20interface\x20is\x20not\x20affected\x20by\x20this\x20option;\ + \x20const\x20methods\x20remain\x20safe\x20to\n\x20call\x20from\x20multip\ + le\x20threads\x20concurrently,\x20while\x20non-const\x20methods\x20conti\ + nue\n\x20to\x20require\x20exclusive\x20access.\n\n\n\x20Note\x20that\x20\ + implementations\x20may\x20choose\x20not\x20to\x20check\x20required\x20fi\ + elds\x20within\n\x20a\x20lazy\x20sub-message.\x20\x20That\x20is,\x20call\ + ing\x20IsInitialized()\x20on\x20the\x20outer\x20message\n\x20may\x20retu\ + rn\x20true\x20even\x20if\x20the\x20inner\x20message\x20has\x20missing\ + \x20required\x20fields.\n\x20This\x20is\x20necessary\x20because\x20other\ + wise\x20the\x20inner\x20message\x20would\x20have\x20to\x20be\n\x20parsed\ + \x20in\x20order\x20to\x20perform\x20the\x20check,\x20defeating\x20the\ + \x20purpose\x20of\x20lazy\n\x20parsing.\x20\x20An\x20implementation\x20w\ + hich\x20chooses\x20not\x20to\x20check\x20required\x20fields\n\x20must\ + \x20be\x20consistent\x20about\x20it.\x20\x20That\x20is,\x20for\x20any\ + \x20particular\x20sub-message,\x20the\n\x20implementation\x20must\x20eit\ + her\x20*always*\x20check\x20its\x20required\x20fields,\x20or\x20*never*\ + \n\x20check\x20its\x20required\x20fields,\x20regardless\x20of\x20whether\ + \x20or\x20not\x20the\x20message\x20has\n\x20been\x20parsed.\n\n\r\n\x05\ + \x04\x0b\x02\x03\x04\x12\x04\x80\x04\x02\n\n\r\n\x05\x04\x0b\x02\x03\x05\ + \x12\x04\x80\x04\x0b\x0f\n\r\n\x05\x04\x0b\x02\x03\x01\x12\x04\x80\x04\ + \x10\x14\n\r\n\x05\x04\x0b\x02\x03\x03\x12\x04\x80\x04\x17\x18\n\r\n\x05\ + \x04\x0b\x02\x03\x08\x12\x04\x80\x04\x19(\n\r\n\x05\x04\x0b\x02\x03\x07\ + \x12\x04\x80\x04\"'\n\xe8\x01\n\x04\x04\x0b\x02\x04\x12\x04\x86\x04\x02/\ + \x1a\xd9\x01\x20Is\x20this\x20field\x20deprecated?\n\x20Depending\x20on\ + \x20the\x20target\x20platform,\x20this\x20can\x20emit\x20Deprecated\x20a\ + nnotations\n\x20for\x20accessors,\x20or\x20it\x20will\x20be\x20completel\ + y\x20ignored;\x20in\x20the\x20very\x20least,\x20this\n\x20is\x20a\x20for\ + malization\x20for\x20deprecating\x20fields.\n\n\r\n\x05\x04\x0b\x02\x04\ + \x04\x12\x04\x86\x04\x02\n\n\r\n\x05\x04\x0b\x02\x04\x05\x12\x04\x86\x04\ + \x0b\x0f\n\r\n\x05\x04\x0b\x02\x04\x01\x12\x04\x86\x04\x10\x1a\n\r\n\x05\ + \x04\x0b\x02\x04\x03\x12\x04\x86\x04\x1d\x1e\n\r\n\x05\x04\x0b\x02\x04\ + \x08\x12\x04\x86\x04\x1f.\n\r\n\x05\x04\x0b\x02\x04\x07\x12\x04\x86\x04(\ + -\n?\n\x04\x04\x0b\x02\x05\x12\x04\x89\x04\x02*\x1a1\x20For\x20Google-in\ + ternal\x20migration\x20only.\x20Do\x20not\x20use.\n\n\r\n\x05\x04\x0b\ + \x02\x05\x04\x12\x04\x89\x04\x02\n\n\r\n\x05\x04\x0b\x02\x05\x05\x12\x04\ + \x89\x04\x0b\x0f\n\r\n\x05\x04\x0b\x02\x05\x01\x12\x04\x89\x04\x10\x14\n\ + \r\n\x05\x04\x0b\x02\x05\x03\x12\x04\x89\x04\x17\x19\n\r\n\x05\x04\x0b\ + \x02\x05\x08\x12\x04\x89\x04\x1a)\n\r\n\x05\x04\x0b\x02\x05\x07\x12\x04\ + \x89\x04#(\nO\n\x04\x04\x0b\x02\x06\x12\x04\x8d\x04\x02:\x1aA\x20The\x20\ + parser\x20stores\x20options\x20it\x20doesn't\x20recognize\x20here.\x20Se\ + e\x20above.\n\n\r\n\x05\x04\x0b\x02\x06\x04\x12\x04\x8d\x04\x02\n\n\r\n\ + \x05\x04\x0b\x02\x06\x06\x12\x04\x8d\x04\x0b\x1e\n\r\n\x05\x04\x0b\x02\ + \x06\x01\x12\x04\x8d\x04\x1f3\n\r\n\x05\x04\x0b\x02\x06\x03\x12\x04\x8d\ + \x0469\nZ\n\x03\x04\x0b\x05\x12\x04\x90\x04\x02\x19\x1aM\x20Clients\x20c\ + an\x20define\x20custom\x20options\x20in\x20extensions\x20of\x20this\x20m\ + essage.\x20See\x20above.\n\n\x0c\n\x04\x04\x0b\x05\0\x12\x04\x90\x04\r\ + \x18\n\r\n\x05\x04\x0b\x05\0\x01\x12\x04\x90\x04\r\x11\n\r\n\x05\x04\x0b\ + \x05\0\x02\x12\x04\x90\x04\x15\x18\n\x0c\n\x02\x04\x0c\x12\x06\x95\x04\0\ + \x9b\x04\x01\n\x0b\n\x03\x04\x0c\x01\x12\x04\x95\x04\x08\x14\nO\n\x04\ + \x04\x0c\x02\0\x12\x04\x97\x04\x02:\x1aA\x20The\x20parser\x20stores\x20o\ + ptions\x20it\x20doesn't\x20recognize\x20here.\x20See\x20above.\n\n\r\n\ + \x05\x04\x0c\x02\0\x04\x12\x04\x97\x04\x02\n\n\r\n\x05\x04\x0c\x02\0\x06\ + \x12\x04\x97\x04\x0b\x1e\n\r\n\x05\x04\x0c\x02\0\x01\x12\x04\x97\x04\x1f\ + 3\n\r\n\x05\x04\x0c\x02\0\x03\x12\x04\x97\x0469\nZ\n\x03\x04\x0c\x05\x12\ + \x04\x9a\x04\x02\x19\x1aM\x20Clients\x20can\x20define\x20custom\x20optio\ + ns\x20in\x20extensions\x20of\x20this\x20message.\x20See\x20above.\n\n\ + \x0c\n\x04\x04\x0c\x05\0\x12\x04\x9a\x04\r\x18\n\r\n\x05\x04\x0c\x05\0\ + \x01\x12\x04\x9a\x04\r\x11\n\r\n\x05\x04\x0c\x05\0\x02\x12\x04\x9a\x04\ + \x15\x18\n\x0c\n\x02\x04\r\x12\x06\x9d\x04\0\xae\x04\x01\n\x0b\n\x03\x04\ + \r\x01\x12\x04\x9d\x04\x08\x13\n`\n\x04\x04\r\x02\0\x12\x04\xa1\x04\x02\ + \x20\x1aR\x20Set\x20this\x20option\x20to\x20true\x20to\x20allow\x20mappi\ + ng\x20different\x20tag\x20names\x20to\x20the\x20same\n\x20value.\n\n\r\n\ + \x05\x04\r\x02\0\x04\x12\x04\xa1\x04\x02\n\n\r\n\x05\x04\r\x02\0\x05\x12\ + \x04\xa1\x04\x0b\x0f\n\r\n\x05\x04\r\x02\0\x01\x12\x04\xa1\x04\x10\x1b\n\ + \r\n\x05\x04\r\x02\0\x03\x12\x04\xa1\x04\x1e\x1f\n\xe5\x01\n\x04\x04\r\ + \x02\x01\x12\x04\xa7\x04\x02/\x1a\xd6\x01\x20Is\x20this\x20enum\x20depre\ + cated?\n\x20Depending\x20on\x20the\x20target\x20platform,\x20this\x20can\ + \x20emit\x20Deprecated\x20annotations\n\x20for\x20the\x20enum,\x20or\x20\ + it\x20will\x20be\x20completely\x20ignored;\x20in\x20the\x20very\x20least\ + ,\x20this\n\x20is\x20a\x20formalization\x20for\x20deprecating\x20enums.\ + \n\n\r\n\x05\x04\r\x02\x01\x04\x12\x04\xa7\x04\x02\n\n\r\n\x05\x04\r\x02\ + \x01\x05\x12\x04\xa7\x04\x0b\x0f\n\r\n\x05\x04\r\x02\x01\x01\x12\x04\xa7\ + \x04\x10\x1a\n\r\n\x05\x04\r\x02\x01\x03\x12\x04\xa7\x04\x1d\x1e\n\r\n\ + \x05\x04\r\x02\x01\x08\x12\x04\xa7\x04\x1f.\n\r\n\x05\x04\r\x02\x01\x07\ + \x12\x04\xa7\x04(-\nO\n\x04\x04\r\x02\x02\x12\x04\xaa\x04\x02:\x1aA\x20T\ + he\x20parser\x20stores\x20options\x20it\x20doesn't\x20recognize\x20here.\ + \x20See\x20above.\n\n\r\n\x05\x04\r\x02\x02\x04\x12\x04\xaa\x04\x02\n\n\ + \r\n\x05\x04\r\x02\x02\x06\x12\x04\xaa\x04\x0b\x1e\n\r\n\x05\x04\r\x02\ + \x02\x01\x12\x04\xaa\x04\x1f3\n\r\n\x05\x04\r\x02\x02\x03\x12\x04\xaa\ + \x0469\nZ\n\x03\x04\r\x05\x12\x04\xad\x04\x02\x19\x1aM\x20Clients\x20can\ + \x20define\x20custom\x20options\x20in\x20extensions\x20of\x20this\x20mes\ + sage.\x20See\x20above.\n\n\x0c\n\x04\x04\r\x05\0\x12\x04\xad\x04\r\x18\n\ + \r\n\x05\x04\r\x05\0\x01\x12\x04\xad\x04\r\x11\n\r\n\x05\x04\r\x05\0\x02\ + \x12\x04\xad\x04\x15\x18\n\x0c\n\x02\x04\x0e\x12\x06\xb0\x04\0\xbc\x04\ + \x01\n\x0b\n\x03\x04\x0e\x01\x12\x04\xb0\x04\x08\x18\n\xf7\x01\n\x04\x04\ + \x0e\x02\0\x12\x04\xb5\x04\x02/\x1a\xe8\x01\x20Is\x20this\x20enum\x20val\ + ue\x20deprecated?\n\x20Depending\x20on\x20the\x20target\x20platform,\x20\ + this\x20can\x20emit\x20Deprecated\x20annotations\n\x20for\x20the\x20enum\ + \x20value,\x20or\x20it\x20will\x20be\x20completely\x20ignored;\x20in\x20\ + the\x20very\x20least,\n\x20this\x20is\x20a\x20formalization\x20for\x20de\ + precating\x20enum\x20values.\n\n\r\n\x05\x04\x0e\x02\0\x04\x12\x04\xb5\ + \x04\x02\n\n\r\n\x05\x04\x0e\x02\0\x05\x12\x04\xb5\x04\x0b\x0f\n\r\n\x05\ + \x04\x0e\x02\0\x01\x12\x04\xb5\x04\x10\x1a\n\r\n\x05\x04\x0e\x02\0\x03\ + \x12\x04\xb5\x04\x1d\x1e\n\r\n\x05\x04\x0e\x02\0\x08\x12\x04\xb5\x04\x1f\ + .\n\r\n\x05\x04\x0e\x02\0\x07\x12\x04\xb5\x04(-\nO\n\x04\x04\x0e\x02\x01\ + \x12\x04\xb8\x04\x02:\x1aA\x20The\x20parser\x20stores\x20options\x20it\ + \x20doesn't\x20recognize\x20here.\x20See\x20above.\n\n\r\n\x05\x04\x0e\ + \x02\x01\x04\x12\x04\xb8\x04\x02\n\n\r\n\x05\x04\x0e\x02\x01\x06\x12\x04\ + \xb8\x04\x0b\x1e\n\r\n\x05\x04\x0e\x02\x01\x01\x12\x04\xb8\x04\x1f3\n\r\ + \n\x05\x04\x0e\x02\x01\x03\x12\x04\xb8\x0469\nZ\n\x03\x04\x0e\x05\x12\ + \x04\xbb\x04\x02\x19\x1aM\x20Clients\x20can\x20define\x20custom\x20optio\ + ns\x20in\x20extensions\x20of\x20this\x20message.\x20See\x20above.\n\n\ + \x0c\n\x04\x04\x0e\x05\0\x12\x04\xbb\x04\r\x18\n\r\n\x05\x04\x0e\x05\0\ + \x01\x12\x04\xbb\x04\r\x11\n\r\n\x05\x04\x0e\x05\0\x02\x12\x04\xbb\x04\ + \x15\x18\n\x0c\n\x02\x04\x0f\x12\x06\xbe\x04\0\xd0\x04\x01\n\x0b\n\x03\ + \x04\x0f\x01\x12\x04\xbe\x04\x08\x16\n\xd9\x03\n\x04\x04\x0f\x02\0\x12\ + \x04\xc9\x04\x020\x1a\xdf\x01\x20Is\x20this\x20service\x20deprecated?\n\ + \x20Depending\x20on\x20the\x20target\x20platform,\x20this\x20can\x20emit\ + \x20Deprecated\x20annotations\n\x20for\x20the\x20service,\x20or\x20it\ + \x20will\x20be\x20completely\x20ignored;\x20in\x20the\x20very\x20least,\ + \n\x20this\x20is\x20a\x20formalization\x20for\x20deprecating\x20services\ + .\n2\xe8\x01\x20Note:\x20\x20Field\x20numbers\x201\x20through\x2032\x20a\ + re\x20reserved\x20for\x20Google's\x20internal\x20RPC\n\x20\x20\x20framew\ + ork.\x20\x20We\x20apologize\x20for\x20hoarding\x20these\x20numbers\x20to\ + \x20ourselves,\x20but\n\x20\x20\x20we\x20were\x20already\x20using\x20the\ + m\x20long\x20before\x20we\x20decided\x20to\x20release\x20Protocol\n\x20\ + \x20\x20Buffers.\n\n\r\n\x05\x04\x0f\x02\0\x04\x12\x04\xc9\x04\x02\n\n\r\ + \n\x05\x04\x0f\x02\0\x05\x12\x04\xc9\x04\x0b\x0f\n\r\n\x05\x04\x0f\x02\0\ + \x01\x12\x04\xc9\x04\x10\x1a\n\r\n\x05\x04\x0f\x02\0\x03\x12\x04\xc9\x04\ + \x1d\x1f\n\r\n\x05\x04\x0f\x02\0\x08\x12\x04\xc9\x04\x20/\n\r\n\x05\x04\ + \x0f\x02\0\x07\x12\x04\xc9\x04).\nO\n\x04\x04\x0f\x02\x01\x12\x04\xcc\ + \x04\x02:\x1aA\x20The\x20parser\x20stores\x20options\x20it\x20doesn't\ + \x20recognize\x20here.\x20See\x20above.\n\n\r\n\x05\x04\x0f\x02\x01\x04\ + \x12\x04\xcc\x04\x02\n\n\r\n\x05\x04\x0f\x02\x01\x06\x12\x04\xcc\x04\x0b\ + \x1e\n\r\n\x05\x04\x0f\x02\x01\x01\x12\x04\xcc\x04\x1f3\n\r\n\x05\x04\ + \x0f\x02\x01\x03\x12\x04\xcc\x0469\nZ\n\x03\x04\x0f\x05\x12\x04\xcf\x04\ + \x02\x19\x1aM\x20Clients\x20can\x20define\x20custom\x20options\x20in\x20\ + extensions\x20of\x20this\x20message.\x20See\x20above.\n\n\x0c\n\x04\x04\ + \x0f\x05\0\x12\x04\xcf\x04\r\x18\n\r\n\x05\x04\x0f\x05\0\x01\x12\x04\xcf\ + \x04\r\x11\n\r\n\x05\x04\x0f\x05\0\x02\x12\x04\xcf\x04\x15\x18\n\x0c\n\ + \x02\x04\x10\x12\x06\xd2\x04\0\xe4\x04\x01\n\x0b\n\x03\x04\x10\x01\x12\ + \x04\xd2\x04\x08\x15\n\xd6\x03\n\x04\x04\x10\x02\0\x12\x04\xdd\x04\x020\ + \x1a\xdc\x01\x20Is\x20this\x20method\x20deprecated?\n\x20Depending\x20on\ + \x20the\x20target\x20platform,\x20this\x20can\x20emit\x20Deprecated\x20a\ + nnotations\n\x20for\x20the\x20method,\x20or\x20it\x20will\x20be\x20compl\ + etely\x20ignored;\x20in\x20the\x20very\x20least,\n\x20this\x20is\x20a\ + \x20formalization\x20for\x20deprecating\x20methods.\n2\xe8\x01\x20Note:\ + \x20\x20Field\x20numbers\x201\x20through\x2032\x20are\x20reserved\x20for\ + \x20Google's\x20internal\x20RPC\n\x20\x20\x20framework.\x20\x20We\x20apo\ + logize\x20for\x20hoarding\x20these\x20numbers\x20to\x20ourselves,\x20but\ + \n\x20\x20\x20we\x20were\x20already\x20using\x20them\x20long\x20before\ + \x20we\x20decided\x20to\x20release\x20Protocol\n\x20\x20\x20Buffers.\n\n\ + \r\n\x05\x04\x10\x02\0\x04\x12\x04\xdd\x04\x02\n\n\r\n\x05\x04\x10\x02\0\ + \x05\x12\x04\xdd\x04\x0b\x0f\n\r\n\x05\x04\x10\x02\0\x01\x12\x04\xdd\x04\ + \x10\x1a\n\r\n\x05\x04\x10\x02\0\x03\x12\x04\xdd\x04\x1d\x1f\n\r\n\x05\ + \x04\x10\x02\0\x08\x12\x04\xdd\x04\x20/\n\r\n\x05\x04\x10\x02\0\x07\x12\ + \x04\xdd\x04).\nO\n\x04\x04\x10\x02\x01\x12\x04\xe0\x04\x02:\x1aA\x20The\ + \x20parser\x20stores\x20options\x20it\x20doesn't\x20recognize\x20here.\ + \x20See\x20above.\n\n\r\n\x05\x04\x10\x02\x01\x04\x12\x04\xe0\x04\x02\n\ + \n\r\n\x05\x04\x10\x02\x01\x06\x12\x04\xe0\x04\x0b\x1e\n\r\n\x05\x04\x10\ + \x02\x01\x01\x12\x04\xe0\x04\x1f3\n\r\n\x05\x04\x10\x02\x01\x03\x12\x04\ + \xe0\x0469\nZ\n\x03\x04\x10\x05\x12\x04\xe3\x04\x02\x19\x1aM\x20Clients\ + \x20can\x20define\x20custom\x20options\x20in\x20extensions\x20of\x20this\ + \x20message.\x20See\x20above.\n\n\x0c\n\x04\x04\x10\x05\0\x12\x04\xe3\ + \x04\r\x18\n\r\n\x05\x04\x10\x05\0\x01\x12\x04\xe3\x04\r\x11\n\r\n\x05\ + \x04\x10\x05\0\x02\x12\x04\xe3\x04\x15\x18\n\x8b\x03\n\x02\x04\x11\x12\ + \x06\xed\x04\0\x81\x05\x01\x1a\xfc\x02\x20A\x20message\x20representing\ + \x20a\x20option\x20the\x20parser\x20does\x20not\x20recognize.\x20This\ + \x20only\n\x20appears\x20in\x20options\x20protos\x20created\x20by\x20the\ + \x20compiler::Parser\x20class.\n\x20DescriptorPool\x20resolves\x20these\ + \x20when\x20building\x20Descriptor\x20objects.\x20Therefore,\n\x20option\ + s\x20protos\x20in\x20descriptor\x20objects\x20(e.g.\x20returned\x20by\ + \x20Descriptor::options(),\n\x20or\x20produced\x20by\x20Descriptor::Copy\ + To())\x20will\x20never\x20have\x20UninterpretedOptions\n\x20in\x20them.\ + \n\n\x0b\n\x03\x04\x11\x01\x12\x04\xed\x04\x08\x1b\n\xcb\x02\n\x04\x04\ + \x11\x03\0\x12\x06\xf3\x04\x02\xf6\x04\x03\x1a\xba\x02\x20The\x20name\ + \x20of\x20the\x20uninterpreted\x20option.\x20\x20Each\x20string\x20repre\ + sents\x20a\x20segment\x20in\n\x20a\x20dot-separated\x20name.\x20\x20is_e\ + xtension\x20is\x20true\x20iff\x20a\x20segment\x20represents\x20an\n\x20e\ + xtension\x20(denoted\x20with\x20parentheses\x20in\x20options\x20specs\ + \x20in\x20.proto\x20files).\n\x20E.g.,{\x20[\"foo\",\x20false],\x20[\"ba\ + r.baz\",\x20true],\x20[\"qux\",\x20false]\x20}\x20represents\n\x20\"foo.\ + (bar.baz).qux\".\n\n\r\n\x05\x04\x11\x03\0\x01\x12\x04\xf3\x04\n\x12\n\ + \x0e\n\x06\x04\x11\x03\0\x02\0\x12\x04\xf4\x04\x04\"\n\x0f\n\x07\x04\x11\ + \x03\0\x02\0\x04\x12\x04\xf4\x04\x04\x0c\n\x0f\n\x07\x04\x11\x03\0\x02\0\ + \x05\x12\x04\xf4\x04\r\x13\n\x0f\n\x07\x04\x11\x03\0\x02\0\x01\x12\x04\ + \xf4\x04\x14\x1d\n\x0f\n\x07\x04\x11\x03\0\x02\0\x03\x12\x04\xf4\x04\x20\ + !\n\x0e\n\x06\x04\x11\x03\0\x02\x01\x12\x04\xf5\x04\x04#\n\x0f\n\x07\x04\ + \x11\x03\0\x02\x01\x04\x12\x04\xf5\x04\x04\x0c\n\x0f\n\x07\x04\x11\x03\0\ + \x02\x01\x05\x12\x04\xf5\x04\r\x11\n\x0f\n\x07\x04\x11\x03\0\x02\x01\x01\ + \x12\x04\xf5\x04\x12\x1e\n\x0f\n\x07\x04\x11\x03\0\x02\x01\x03\x12\x04\ + \xf5\x04!\"\n\x0c\n\x04\x04\x11\x02\0\x12\x04\xf7\x04\x02\x1d\n\r\n\x05\ + \x04\x11\x02\0\x04\x12\x04\xf7\x04\x02\n\n\r\n\x05\x04\x11\x02\0\x06\x12\ + \x04\xf7\x04\x0b\x13\n\r\n\x05\x04\x11\x02\0\x01\x12\x04\xf7\x04\x14\x18\ + \n\r\n\x05\x04\x11\x02\0\x03\x12\x04\xf7\x04\x1b\x1c\n\x9c\x01\n\x04\x04\ + \x11\x02\x01\x12\x04\xfb\x04\x02'\x1a\x8d\x01\x20The\x20value\x20of\x20t\ + he\x20uninterpreted\x20option,\x20in\x20whatever\x20type\x20the\x20token\ + izer\n\x20identified\x20it\x20as\x20during\x20parsing.\x20Exactly\x20one\ + \x20of\x20these\x20should\x20be\x20set.\n\n\r\n\x05\x04\x11\x02\x01\x04\ + \x12\x04\xfb\x04\x02\n\n\r\n\x05\x04\x11\x02\x01\x05\x12\x04\xfb\x04\x0b\ + \x11\n\r\n\x05\x04\x11\x02\x01\x01\x12\x04\xfb\x04\x12\"\n\r\n\x05\x04\ + \x11\x02\x01\x03\x12\x04\xfb\x04%&\n\x0c\n\x04\x04\x11\x02\x02\x12\x04\ + \xfc\x04\x02)\n\r\n\x05\x04\x11\x02\x02\x04\x12\x04\xfc\x04\x02\n\n\r\n\ + \x05\x04\x11\x02\x02\x05\x12\x04\xfc\x04\x0b\x11\n\r\n\x05\x04\x11\x02\ + \x02\x01\x12\x04\xfc\x04\x12$\n\r\n\x05\x04\x11\x02\x02\x03\x12\x04\xfc\ + \x04'(\n\x0c\n\x04\x04\x11\x02\x03\x12\x04\xfd\x04\x02(\n\r\n\x05\x04\ + \x11\x02\x03\x04\x12\x04\xfd\x04\x02\n\n\r\n\x05\x04\x11\x02\x03\x05\x12\ + \x04\xfd\x04\x0b\x10\n\r\n\x05\x04\x11\x02\x03\x01\x12\x04\xfd\x04\x11#\ + \n\r\n\x05\x04\x11\x02\x03\x03\x12\x04\xfd\x04&'\n\x0c\n\x04\x04\x11\x02\ + \x04\x12\x04\xfe\x04\x02#\n\r\n\x05\x04\x11\x02\x04\x04\x12\x04\xfe\x04\ + \x02\n\n\r\n\x05\x04\x11\x02\x04\x05\x12\x04\xfe\x04\x0b\x11\n\r\n\x05\ + \x04\x11\x02\x04\x01\x12\x04\xfe\x04\x12\x1e\n\r\n\x05\x04\x11\x02\x04\ + \x03\x12\x04\xfe\x04!\"\n\x0c\n\x04\x04\x11\x02\x05\x12\x04\xff\x04\x02\ + \"\n\r\n\x05\x04\x11\x02\x05\x04\x12\x04\xff\x04\x02\n\n\r\n\x05\x04\x11\ + \x02\x05\x05\x12\x04\xff\x04\x0b\x10\n\r\n\x05\x04\x11\x02\x05\x01\x12\ + \x04\xff\x04\x11\x1d\n\r\n\x05\x04\x11\x02\x05\x03\x12\x04\xff\x04\x20!\ + \n\x0c\n\x04\x04\x11\x02\x06\x12\x04\x80\x05\x02&\n\r\n\x05\x04\x11\x02\ + \x06\x04\x12\x04\x80\x05\x02\n\n\r\n\x05\x04\x11\x02\x06\x05\x12\x04\x80\ + \x05\x0b\x11\n\r\n\x05\x04\x11\x02\x06\x01\x12\x04\x80\x05\x12!\n\r\n\ + \x05\x04\x11\x02\x06\x03\x12\x04\x80\x05$%\n\xda\x01\n\x02\x04\x12\x12\ + \x06\x88\x05\0\x89\x06\x01\x1aj\x20Encapsulates\x20information\x20about\ + \x20the\x20original\x20source\x20file\x20from\x20which\x20a\n\x20FileDes\ + criptorProto\x20was\x20generated.\n2`\x20===============================\ + ====================================\n\x20Optional\x20source\x20code\x20\ + info\n\n\x0b\n\x03\x04\x12\x01\x12\x04\x88\x05\x08\x16\n\x82\x11\n\x04\ + \x04\x12\x02\0\x12\x04\xb4\x05\x02!\x1a\xf3\x10\x20A\x20Location\x20iden\ + tifies\x20a\x20piece\x20of\x20source\x20code\x20in\x20a\x20.proto\x20fil\ + e\x20which\n\x20corresponds\x20to\x20a\x20particular\x20definition.\x20\ + \x20This\x20information\x20is\x20intended\n\x20to\x20be\x20useful\x20to\ + \x20IDEs,\x20code\x20indexers,\x20documentation\x20generators,\x20and\ + \x20similar\n\x20tools.\n\n\x20For\x20example,\x20say\x20we\x20have\x20a\ + \x20file\x20like:\n\x20\x20\x20message\x20Foo\x20{\n\x20\x20\x20\x20\x20\ + optional\x20string\x20foo\x20=\x201;\n\x20\x20\x20}\n\x20Let's\x20look\ + \x20at\x20just\x20the\x20field\x20definition:\n\x20\x20\x20optional\x20s\ + tring\x20foo\x20=\x201;\n\x20\x20\x20^\x20\x20\x20\x20\x20\x20\x20^^\x20\ + \x20\x20\x20\x20^^\x20\x20^\x20\x20^^^\n\x20\x20\x20a\x20\x20\x20\x20\ + \x20\x20\x20bc\x20\x20\x20\x20\x20de\x20\x20f\x20\x20ghi\n\x20We\x20have\ + \x20the\x20following\x20locations:\n\x20\x20\x20span\x20\x20\x20path\x20\ + \x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20represents\n\x20\ + \x20\x20[a,i)\x20\x20[\x204,\x200,\x202,\x200\x20]\x20\x20\x20\x20\x20Th\ + e\x20whole\x20field\x20definition.\n\x20\x20\x20[a,b)\x20\x20[\x204,\x20\ + 0,\x202,\x200,\x204\x20]\x20\x20The\x20label\x20(optional).\n\x20\x20\ + \x20[c,d)\x20\x20[\x204,\x200,\x202,\x200,\x205\x20]\x20\x20The\x20type\ + \x20(string).\n\x20\x20\x20[e,f)\x20\x20[\x204,\x200,\x202,\x200,\x201\ + \x20]\x20\x20The\x20name\x20(foo).\n\x20\x20\x20[g,h)\x20\x20[\x204,\x20\ + 0,\x202,\x200,\x203\x20]\x20\x20The\x20number\x20(1).\n\n\x20Notes:\n\ + \x20-\x20A\x20location\x20may\x20refer\x20to\x20a\x20repeated\x20field\ + \x20itself\x20(i.e.\x20not\x20to\x20any\n\x20\x20\x20particular\x20index\ + \x20within\x20it).\x20\x20This\x20is\x20used\x20whenever\x20a\x20set\x20\ + of\x20elements\x20are\n\x20\x20\x20logically\x20enclosed\x20in\x20a\x20s\ + ingle\x20code\x20segment.\x20\x20For\x20example,\x20an\x20entire\n\x20\ + \x20\x20extend\x20block\x20(possibly\x20containing\x20multiple\x20extens\ + ion\x20definitions)\x20will\n\x20\x20\x20have\x20an\x20outer\x20location\ + \x20whose\x20path\x20refers\x20to\x20the\x20\"extensions\"\x20repeated\n\ + \x20\x20\x20field\x20without\x20an\x20index.\n\x20-\x20Multiple\x20locat\ + ions\x20may\x20have\x20the\x20same\x20path.\x20\x20This\x20happens\x20wh\ + en\x20a\x20single\n\x20\x20\x20logical\x20declaration\x20is\x20spread\ + \x20out\x20across\x20multiple\x20places.\x20\x20The\x20most\n\x20\x20\ + \x20obvious\x20example\x20is\x20the\x20\"extend\"\x20block\x20again\x20-\ + -\x20there\x20may\x20be\x20multiple\n\x20\x20\x20extend\x20blocks\x20in\ + \x20the\x20same\x20scope,\x20each\x20of\x20which\x20will\x20have\x20the\ + \x20same\x20path.\n\x20-\x20A\x20location's\x20span\x20is\x20not\x20alwa\ + ys\x20a\x20subset\x20of\x20its\x20parent's\x20span.\x20\x20For\n\x20\x20\ + \x20example,\x20the\x20\"extendee\"\x20of\x20an\x20extension\x20declarat\ + ion\x20appears\x20at\x20the\n\x20\x20\x20beginning\x20of\x20the\x20\"ext\ + end\"\x20block\x20and\x20is\x20shared\x20by\x20all\x20extensions\x20with\ + in\n\x20\x20\x20the\x20block.\n\x20-\x20Just\x20because\x20a\x20location\ + 's\x20span\x20is\x20a\x20subset\x20of\x20some\x20other\x20location's\x20\ + span\n\x20\x20\x20does\x20not\x20mean\x20that\x20it\x20is\x20a\x20descen\ + dent.\x20\x20For\x20example,\x20a\x20\"group\"\x20defines\n\x20\x20\x20b\ + oth\x20a\x20type\x20and\x20a\x20field\x20in\x20a\x20single\x20declaratio\ + n.\x20\x20Thus,\x20the\x20locations\n\x20\x20\x20corresponding\x20to\x20\ + the\x20type\x20and\x20field\x20and\x20their\x20components\x20will\x20ove\ + rlap.\n\x20-\x20Code\x20which\x20tries\x20to\x20interpret\x20locations\ + \x20should\x20probably\x20be\x20designed\x20to\n\x20\x20\x20ignore\x20th\ + ose\x20that\x20it\x20doesn't\x20understand,\x20as\x20more\x20types\x20of\ + \x20locations\x20could\n\x20\x20\x20be\x20recorded\x20in\x20the\x20futur\ + e.\n\n\r\n\x05\x04\x12\x02\0\x04\x12\x04\xb4\x05\x02\n\n\r\n\x05\x04\x12\ + \x02\0\x06\x12\x04\xb4\x05\x0b\x13\n\r\n\x05\x04\x12\x02\0\x01\x12\x04\ + \xb4\x05\x14\x1c\n\r\n\x05\x04\x12\x02\0\x03\x12\x04\xb4\x05\x1f\x20\n\ + \x0e\n\x04\x04\x12\x03\0\x12\x06\xb5\x05\x02\x88\x06\x03\n\r\n\x05\x04\ + \x12\x03\0\x01\x12\x04\xb5\x05\n\x12\n\x83\x07\n\x06\x04\x12\x03\0\x02\0\ + \x12\x04\xcd\x05\x04*\x1a\xf2\x06\x20Identifies\x20which\x20part\x20of\ + \x20the\x20FileDescriptorProto\x20was\x20defined\x20at\x20this\n\x20loca\ + tion.\n\n\x20Each\x20element\x20is\x20a\x20field\x20number\x20or\x20an\ + \x20index.\x20\x20They\x20form\x20a\x20path\x20from\n\x20the\x20root\x20\ + FileDescriptorProto\x20to\x20the\x20place\x20where\x20the\x20definition.\ + \x20\x20For\n\x20example,\x20this\x20path:\n\x20\x20\x20[\x204,\x203,\ + \x202,\x207,\x201\x20]\n\x20refers\x20to:\n\x20\x20\x20file.message_type\ + (3)\x20\x20//\x204,\x203\n\x20\x20\x20\x20\x20\x20\x20.field(7)\x20\x20\ + \x20\x20\x20\x20\x20\x20\x20//\x202,\x207\n\x20\x20\x20\x20\x20\x20\x20.\ + name()\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x201\n\x20This\x20i\ + s\x20because\x20FileDescriptorProto.message_type\x20has\x20field\x20numb\ + er\x204:\n\x20\x20\x20repeated\x20DescriptorProto\x20message_type\x20=\ + \x204;\n\x20and\x20DescriptorProto.field\x20has\x20field\x20number\x202:\ + \n\x20\x20\x20repeated\x20FieldDescriptorProto\x20field\x20=\x202;\n\x20\ + and\x20FieldDescriptorProto.name\x20has\x20field\x20number\x201:\n\x20\ + \x20\x20optional\x20string\x20name\x20=\x201;\n\n\x20Thus,\x20the\x20abo\ + ve\x20path\x20gives\x20the\x20location\x20of\x20a\x20field\x20name.\x20\ + \x20If\x20we\x20removed\n\x20the\x20last\x20element:\n\x20\x20\x20[\x204\ + ,\x203,\x202,\x207\x20]\n\x20this\x20path\x20refers\x20to\x20the\x20whol\ + e\x20field\x20declaration\x20(from\x20the\x20beginning\n\x20of\x20the\ + \x20label\x20to\x20the\x20terminating\x20semicolon).\n\n\x0f\n\x07\x04\ + \x12\x03\0\x02\0\x04\x12\x04\xcd\x05\x04\x0c\n\x0f\n\x07\x04\x12\x03\0\ + \x02\0\x05\x12\x04\xcd\x05\r\x12\n\x0f\n\x07\x04\x12\x03\0\x02\0\x01\x12\ + \x04\xcd\x05\x13\x17\n\x0f\n\x07\x04\x12\x03\0\x02\0\x03\x12\x04\xcd\x05\ + \x1a\x1b\n\x0f\n\x07\x04\x12\x03\0\x02\0\x08\x12\x04\xcd\x05\x1c)\n\x12\ + \n\n\x04\x12\x03\0\x02\0\x08\xe7\x07\0\x12\x04\xcd\x05\x1d(\n\x13\n\x0b\ + \x04\x12\x03\0\x02\0\x08\xe7\x07\0\x02\x12\x04\xcd\x05\x1d#\n\x14\n\x0c\ + \x04\x12\x03\0\x02\0\x08\xe7\x07\0\x02\0\x12\x04\xcd\x05\x1d#\n\x15\n\r\ + \x04\x12\x03\0\x02\0\x08\xe7\x07\0\x02\0\x01\x12\x04\xcd\x05\x1d#\n\x13\ + \n\x0b\x04\x12\x03\0\x02\0\x08\xe7\x07\0\x03\x12\x04\xcd\x05$(\n\xd2\x02\ + \n\x06\x04\x12\x03\0\x02\x01\x12\x04\xd4\x05\x04*\x1a\xc1\x02\x20Always\ + \x20has\x20exactly\x20three\x20or\x20four\x20elements:\x20start\x20line,\ + \x20start\x20column,\n\x20end\x20line\x20(optional,\x20otherwise\x20assu\ + med\x20same\x20as\x20start\x20line),\x20end\x20column.\n\x20These\x20are\ + \x20packed\x20into\x20a\x20single\x20field\x20for\x20efficiency.\x20\x20\ + Note\x20that\x20line\n\x20and\x20column\x20numbers\x20are\x20zero-based\ + \x20--\x20typically\x20you\x20will\x20want\x20to\x20add\n\x201\x20to\x20\ + each\x20before\x20displaying\x20to\x20a\x20user.\n\n\x0f\n\x07\x04\x12\ + \x03\0\x02\x01\x04\x12\x04\xd4\x05\x04\x0c\n\x0f\n\x07\x04\x12\x03\0\x02\ + \x01\x05\x12\x04\xd4\x05\r\x12\n\x0f\n\x07\x04\x12\x03\0\x02\x01\x01\x12\ + \x04\xd4\x05\x13\x17\n\x0f\n\x07\x04\x12\x03\0\x02\x01\x03\x12\x04\xd4\ + \x05\x1a\x1b\n\x0f\n\x07\x04\x12\x03\0\x02\x01\x08\x12\x04\xd4\x05\x1c)\ + \n\x12\n\n\x04\x12\x03\0\x02\x01\x08\xe7\x07\0\x12\x04\xd4\x05\x1d(\n\ + \x13\n\x0b\x04\x12\x03\0\x02\x01\x08\xe7\x07\0\x02\x12\x04\xd4\x05\x1d#\ + \n\x14\n\x0c\x04\x12\x03\0\x02\x01\x08\xe7\x07\0\x02\0\x12\x04\xd4\x05\ + \x1d#\n\x15\n\r\x04\x12\x03\0\x02\x01\x08\xe7\x07\0\x02\0\x01\x12\x04\ + \xd4\x05\x1d#\n\x13\n\x0b\x04\x12\x03\0\x02\x01\x08\xe7\x07\0\x03\x12\ + \x04\xd4\x05$(\n\xa5\x0c\n\x06\x04\x12\x03\0\x02\x02\x12\x04\x85\x06\x04\ + )\x1a\x94\x0c\x20If\x20this\x20SourceCodeInfo\x20represents\x20a\x20comp\ + lete\x20declaration,\x20these\x20are\x20any\n\x20comments\x20appearing\ + \x20before\x20and\x20after\x20the\x20declaration\x20which\x20appear\x20t\ + o\x20be\n\x20attached\x20to\x20the\x20declaration.\n\n\x20A\x20series\ + \x20of\x20line\x20comments\x20appearing\x20on\x20consecutive\x20lines,\ + \x20with\x20no\x20other\n\x20tokens\x20appearing\x20on\x20those\x20lines\ + ,\x20will\x20be\x20treated\x20as\x20a\x20single\x20comment.\n\n\x20leadi\ + ng_detached_comments\x20will\x20keep\x20paragraphs\x20of\x20comments\x20\ + that\x20appear\n\x20before\x20(but\x20not\x20connected\x20to)\x20the\x20\ + current\x20element.\x20Each\x20paragraph,\n\x20separated\x20by\x20empty\ + \x20lines,\x20will\x20be\x20one\x20comment\x20element\x20in\x20the\x20re\ + peated\n\x20field.\n\n\x20Only\x20the\x20comment\x20content\x20is\x20pro\ + vided;\x20comment\x20markers\x20(e.g.\x20//)\x20are\n\x20stripped\x20out\ + .\x20\x20For\x20block\x20comments,\x20leading\x20whitespace\x20and\x20an\ + \x20asterisk\n\x20will\x20be\x20stripped\x20from\x20the\x20beginning\x20\ + of\x20each\x20line\x20other\x20than\x20the\x20first.\n\x20Newlines\x20ar\ + e\x20included\x20in\x20the\x20output.\n\n\x20Examples:\n\n\x20\x20\x20op\ + tional\x20int32\x20foo\x20=\x201;\x20\x20//\x20Comment\x20attached\x20to\ + \x20foo.\n\x20\x20\x20//\x20Comment\x20attached\x20to\x20bar.\n\x20\x20\ + \x20optional\x20int32\x20bar\x20=\x202;\n\n\x20\x20\x20optional\x20strin\ + g\x20baz\x20=\x203;\n\x20\x20\x20//\x20Comment\x20attached\x20to\x20baz.\ + \n\x20\x20\x20//\x20Another\x20line\x20attached\x20to\x20baz.\n\n\x20\ + \x20\x20//\x20Comment\x20attached\x20to\x20qux.\n\x20\x20\x20//\n\x20\ + \x20\x20//\x20Another\x20line\x20attached\x20to\x20qux.\n\x20\x20\x20opt\ + ional\x20double\x20qux\x20=\x204;\n\n\x20\x20\x20//\x20Detached\x20comme\ + nt\x20for\x20corge.\x20This\x20is\x20not\x20leading\x20or\x20trailing\ + \x20comments\n\x20\x20\x20//\x20to\x20qux\x20or\x20corge\x20because\x20t\ + here\x20are\x20blank\x20lines\x20separating\x20it\x20from\n\x20\x20\x20/\ + /\x20both.\n\n\x20\x20\x20//\x20Detached\x20comment\x20for\x20corge\x20p\ + aragraph\x202.\n\n\x20\x20\x20optional\x20string\x20corge\x20=\x205;\n\ + \x20\x20\x20/*\x20Block\x20comment\x20attached\n\x20\x20\x20\x20*\x20to\ + \x20corge.\x20\x20Leading\x20asterisks\n\x20\x20\x20\x20*\x20will\x20be\ + \x20removed.\x20*/\n\x20\x20\x20/*\x20Block\x20comment\x20attached\x20to\ + \n\x20\x20\x20\x20*\x20grault.\x20*/\n\x20\x20\x20optional\x20int32\x20g\ + rault\x20=\x206;\n\n\x20\x20\x20//\x20ignored\x20detached\x20comments.\n\ + \n\x0f\n\x07\x04\x12\x03\0\x02\x02\x04\x12\x04\x85\x06\x04\x0c\n\x0f\n\ + \x07\x04\x12\x03\0\x02\x02\x05\x12\x04\x85\x06\r\x13\n\x0f\n\x07\x04\x12\ + \x03\0\x02\x02\x01\x12\x04\x85\x06\x14$\n\x0f\n\x07\x04\x12\x03\0\x02\ + \x02\x03\x12\x04\x85\x06'(\n\x0e\n\x06\x04\x12\x03\0\x02\x03\x12\x04\x86\ + \x06\x04*\n\x0f\n\x07\x04\x12\x03\0\x02\x03\x04\x12\x04\x86\x06\x04\x0c\ + \n\x0f\n\x07\x04\x12\x03\0\x02\x03\x05\x12\x04\x86\x06\r\x13\n\x0f\n\x07\ + \x04\x12\x03\0\x02\x03\x01\x12\x04\x86\x06\x14%\n\x0f\n\x07\x04\x12\x03\ + \0\x02\x03\x03\x12\x04\x86\x06()\n\x0e\n\x06\x04\x12\x03\0\x02\x04\x12\ + \x04\x87\x06\x042\n\x0f\n\x07\x04\x12\x03\0\x02\x04\x04\x12\x04\x87\x06\ + \x04\x0c\n\x0f\n\x07\x04\x12\x03\0\x02\x04\x05\x12\x04\x87\x06\r\x13\n\ + \x0f\n\x07\x04\x12\x03\0\x02\x04\x01\x12\x04\x87\x06\x14-\n\x0f\n\x07\ + \x04\x12\x03\0\x02\x04\x03\x12\x04\x87\x0601\n\xee\x01\n\x02\x04\x13\x12\ + \x06\x8e\x06\0\xa3\x06\x01\x1a\xdf\x01\x20Describes\x20the\x20relationsh\ + ip\x20between\x20generated\x20code\x20and\x20its\x20original\x20source\n\ + \x20file.\x20A\x20GeneratedCodeInfo\x20message\x20is\x20associated\x20wi\ + th\x20only\x20one\x20generated\n\x20source\x20file,\x20but\x20may\x20con\ + tain\x20references\x20to\x20different\x20source\x20.proto\x20files.\n\n\ + \x0b\n\x03\x04\x13\x01\x12\x04\x8e\x06\x08\x19\nx\n\x04\x04\x13\x02\0\ + \x12\x04\x91\x06\x02%\x1aj\x20An\x20Annotation\x20connects\x20some\x20sp\ + an\x20of\x20text\x20in\x20generated\x20code\x20to\x20an\x20element\n\x20\ + of\x20its\x20generating\x20.proto\x20file.\n\n\r\n\x05\x04\x13\x02\0\x04\ + \x12\x04\x91\x06\x02\n\n\r\n\x05\x04\x13\x02\0\x06\x12\x04\x91\x06\x0b\ + \x15\n\r\n\x05\x04\x13\x02\0\x01\x12\x04\x91\x06\x16\x20\n\r\n\x05\x04\ + \x13\x02\0\x03\x12\x04\x91\x06#$\n\x0e\n\x04\x04\x13\x03\0\x12\x06\x92\ + \x06\x02\xa2\x06\x03\n\r\n\x05\x04\x13\x03\0\x01\x12\x04\x92\x06\n\x14\n\ + \x8f\x01\n\x06\x04\x13\x03\0\x02\0\x12\x04\x95\x06\x04*\x1a\x7f\x20Ident\ + ifies\x20the\x20element\x20in\x20the\x20original\x20source\x20.proto\x20\ + file.\x20This\x20field\n\x20is\x20formatted\x20the\x20same\x20as\x20Sour\ + ceCodeInfo.Location.path.\n\n\x0f\n\x07\x04\x13\x03\0\x02\0\x04\x12\x04\ + \x95\x06\x04\x0c\n\x0f\n\x07\x04\x13\x03\0\x02\0\x05\x12\x04\x95\x06\r\ + \x12\n\x0f\n\x07\x04\x13\x03\0\x02\0\x01\x12\x04\x95\x06\x13\x17\n\x0f\n\ + \x07\x04\x13\x03\0\x02\0\x03\x12\x04\x95\x06\x1a\x1b\n\x0f\n\x07\x04\x13\ + \x03\0\x02\0\x08\x12\x04\x95\x06\x1c)\n\x12\n\n\x04\x13\x03\0\x02\0\x08\ + \xe7\x07\0\x12\x04\x95\x06\x1d(\n\x13\n\x0b\x04\x13\x03\0\x02\0\x08\xe7\ + \x07\0\x02\x12\x04\x95\x06\x1d#\n\x14\n\x0c\x04\x13\x03\0\x02\0\x08\xe7\ + \x07\0\x02\0\x12\x04\x95\x06\x1d#\n\x15\n\r\x04\x13\x03\0\x02\0\x08\xe7\ + \x07\0\x02\0\x01\x12\x04\x95\x06\x1d#\n\x13\n\x0b\x04\x13\x03\0\x02\0\ + \x08\xe7\x07\0\x03\x12\x04\x95\x06$(\nO\n\x06\x04\x13\x03\0\x02\x01\x12\ + \x04\x98\x06\x04$\x1a?\x20Identifies\x20the\x20filesystem\x20path\x20to\ + \x20the\x20original\x20source\x20.proto.\n\n\x0f\n\x07\x04\x13\x03\0\x02\ + \x01\x04\x12\x04\x98\x06\x04\x0c\n\x0f\n\x07\x04\x13\x03\0\x02\x01\x05\ + \x12\x04\x98\x06\r\x13\n\x0f\n\x07\x04\x13\x03\0\x02\x01\x01\x12\x04\x98\ + \x06\x14\x1f\n\x0f\n\x07\x04\x13\x03\0\x02\x01\x03\x12\x04\x98\x06\"#\nw\ + \n\x06\x04\x13\x03\0\x02\x02\x12\x04\x9c\x06\x04\x1d\x1ag\x20Identifies\ + \x20the\x20starting\x20offset\x20in\x20bytes\x20in\x20the\x20generated\ + \x20code\n\x20that\x20relates\x20to\x20the\x20identified\x20object.\n\n\ + \x0f\n\x07\x04\x13\x03\0\x02\x02\x04\x12\x04\x9c\x06\x04\x0c\n\x0f\n\x07\ + \x04\x13\x03\0\x02\x02\x05\x12\x04\x9c\x06\r\x12\n\x0f\n\x07\x04\x13\x03\ + \0\x02\x02\x01\x12\x04\x9c\x06\x13\x18\n\x0f\n\x07\x04\x13\x03\0\x02\x02\ + \x03\x12\x04\x9c\x06\x1b\x1c\n\xdb\x01\n\x06\x04\x13\x03\0\x02\x03\x12\ + \x04\xa1\x06\x04\x1b\x1a\xca\x01\x20Identifies\x20the\x20ending\x20offse\ + t\x20in\x20bytes\x20in\x20the\x20generated\x20code\x20that\n\x20relates\ + \x20to\x20the\x20identified\x20offset.\x20The\x20end\x20offset\x20should\ + \x20be\x20one\x20past\n\x20the\x20last\x20relevant\x20byte\x20(so\x20the\ + \x20length\x20of\x20the\x20text\x20=\x20end\x20-\x20begin).\n\n\x0f\n\ + \x07\x04\x13\x03\0\x02\x03\x04\x12\x04\xa1\x06\x04\x0c\n\x0f\n\x07\x04\ + \x13\x03\0\x02\x03\x05\x12\x04\xa1\x06\r\x12\n\x0f\n\x07\x04\x13\x03\0\ + \x02\x03\x01\x12\x04\xa1\x06\x13\x16\n\x0f\n\x07\x04\x13\x03\0\x02\x03\ + \x03\x12\x04\xa1\x06\x19\x1a\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/third_party/protobuf/src/descriptorx.rs b/third_party/protobuf/src/descriptorx.rs new file mode 100644 index 000000000..603afd655 --- /dev/null +++ b/third_party/protobuf/src/descriptorx.rs @@ -0,0 +1,623 @@ +/// utilities to work with descriptor + +use std::string::String; +use std::string::ToString; +use std::vec::Vec; +use std::slice::SliceConcatExt; + +use descriptor::FileDescriptorProto; +use descriptor::DescriptorProto; +use descriptor::EnumDescriptorProto; +use descriptor::EnumValueDescriptorProto; +use descriptor::FieldDescriptorProto; +use descriptor::OneofDescriptorProto; + +use strx; +use rust; + + +// Copy-pasted from libsyntax. +fn ident_start(c: char) -> bool { + (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' +} + +// Copy-pasted from libsyntax. +fn ident_continue(c: char) -> bool { + (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' +} + +pub fn proto_path_to_rust_mod(path: &str) -> String { + let without_dir = strx::remove_to(path, '/'); + let without_suffix = strx::remove_suffix(without_dir, ".proto") + .expect(&format!("file name must end with .proto: {}", path)); + + let name = without_suffix + .chars() + .enumerate() + .map(|(i, c)| { + let valid = if i == 0 { + ident_start(c) + } else { + ident_continue(c) + }; + if valid { c } else { '_' } + }) + .collect::(); + + let name = if rust::is_rust_keyword(&name) { + format!("{}_pb", name) + } else { + name + }; + name +} + + +pub struct RootScope<'a> { + pub file_descriptors: &'a [FileDescriptorProto], +} + +impl<'a> RootScope<'a> { + fn packages(&'a self) -> Vec> { + self.file_descriptors + .iter() + .map(|fd| FileScope { file_descriptor: fd }) + .collect() + } + + // find enum by fully qualified name + pub fn find_enum(&'a self, fqn: &str) -> EnumWithScope<'a> { + match self.find_message_or_enum(fqn) { + MessageOrEnumWithScope::Enum(e) => e, + _ => panic!("not an enum: {}", fqn), + } + } + + // find message by fully qualified name + pub fn find_message(&'a self, fqn: &str) -> MessageWithScope<'a> { + match self.find_message_or_enum(fqn) { + MessageOrEnumWithScope::Message(m) => m, + _ => panic!("not a message: {}", fqn), + } + } + + // find message or enum by fully qualified name + pub fn find_message_or_enum(&'a self, fqn: &str) -> MessageOrEnumWithScope<'a> { + assert!(fqn.starts_with("."), "name must start with dot: {}", fqn); + let fqn1 = &fqn[1..]; + self.packages() + .into_iter() + .flat_map(|p| { + (if p.get_package().is_empty() { + p.find_message_or_enum(fqn1) + } else if fqn1.starts_with(&(p.get_package().to_string() + ".")) { + let remaining = &fqn1[(p.get_package().len() + 1)..]; + p.find_message_or_enum(remaining) + } else { + None + }).into_iter() + }) + .next() + .expect(&format!("enum not found by name: {}", fqn)) + } +} + + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum Syntax { + PROTO2, + PROTO3, +} + +impl Syntax { + pub fn parse(s: &str) -> Self { + match s { + "" | "proto2" => Syntax::PROTO2, + "proto3" => Syntax::PROTO3, + _ => panic!("unsupported syntax value: {:?}", s), + } + } +} + + +#[derive(Clone)] +pub struct FileScope<'a> { + pub file_descriptor: &'a FileDescriptorProto, +} + +impl<'a> FileScope<'a> { + fn get_package(&self) -> &'a str { + self.file_descriptor.get_package() + } + + pub fn syntax(&self) -> Syntax { + Syntax::parse(self.file_descriptor.get_syntax()) + } + + pub fn to_scope(&self) -> Scope<'a> { + Scope { + file_scope: self.clone(), + path: Vec::new(), + } + } + + fn find_message_or_enum(&self, name: &str) -> Option> { + assert!(!name.starts_with(".")); + self.find_messages_and_enums() + .into_iter() + .filter(|e| e.name_to_package() == name) + .next() + } + + // find all enums in given file descriptor + pub fn find_enums(&self) -> Vec> { + let mut r = Vec::new(); + + self.to_scope() + .walk_scopes(|scope| { r.extend(scope.get_enums()); }); + + r + } + + // find all messages in given file descriptor + pub fn find_messages(&self) -> Vec> { + let mut r = Vec::new(); + + self.to_scope() + .walk_scopes(|scope| { r.extend(scope.get_messages()); }); + + r + } + + // find all messages and enums in given file descriptor + pub fn find_messages_and_enums(&self) -> Vec> { + let mut r = Vec::new(); + + self.to_scope() + .walk_scopes(|scope| { r.extend(scope.get_messages_and_enums()); }); + + r + } +} + + +#[derive(Clone)] +pub struct Scope<'a> { + pub file_scope: FileScope<'a>, + pub path: Vec<&'a DescriptorProto>, +} + + +impl<'a> Scope<'a> { + pub fn get_file_descriptor(&self) -> &'a FileDescriptorProto { + self.file_scope.file_descriptor + } + + // get message descriptors in this scope + fn get_message_descriptors(&self) -> &'a [DescriptorProto] { + if self.path.is_empty() { + self.file_scope.file_descriptor.get_message_type() + } else { + self.path.last().unwrap().get_nested_type() + } + } + + // get enum descriptors in this scope + fn get_enum_descriptors(&self) -> &'a [EnumDescriptorProto] { + if self.path.is_empty() { + self.file_scope.file_descriptor.get_enum_type() + } else { + self.path.last().unwrap().get_enum_type() + } + } + + // get messages with attached scopes in this scope + pub fn get_messages(&self) -> Vec> { + self.get_message_descriptors() + .iter() + .map(|m| { + MessageWithScope { + scope: self.clone(), + message: m, + } + }) + .collect() + } + + // get enums with attached scopes in this scope + pub fn get_enums(&self) -> Vec> { + self.get_enum_descriptors() + .iter() + .map(|e| { + EnumWithScope { + scope: self.clone(), + en: e, + } + }) + .collect() + } + + // get messages and enums with attached scopes in this scope + pub fn get_messages_and_enums(&self) -> Vec> { + self.get_messages() + .into_iter() + .map(|m| MessageOrEnumWithScope::Message(m)) + .chain( + self.get_enums() + .into_iter() + .map(|m| MessageOrEnumWithScope::Enum(m)), + ) + .collect() + } + + // nested scopes, i. e. scopes of nested messages + fn nested_scopes(&self) -> Vec> { + self.get_message_descriptors() + .iter() + .map(|m| { + let mut nested = self.clone(); + nested.path.push(m); + nested + }) + .collect() + } + + fn walk_scopes_impl)>(&self, callback: &mut F) { + (*callback)(self); + + for nested in self.nested_scopes() { + nested.walk_scopes_impl(callback); + } + } + + // apply callback for this scope and all nested scopes + fn walk_scopes(&self, mut callback: F) + where + F : FnMut(&Scope<'a>), + { + self.walk_scopes_impl(&mut callback); + } + + pub fn prefix(&self) -> String { + if self.path.is_empty() { + "".to_string() + } else { + let v: Vec<&'a str> = self.path.iter().map(|m| m.get_name()).collect(); + let mut r = v.join("."); + r.push_str("."); + r + } + } + + // rust type name prefix for this scope + pub fn rust_prefix(&self) -> String { + self.prefix().replace(".", "_") + } +} + +pub trait WithScope<'a> { + fn get_scope(&self) -> &Scope<'a>; + + fn get_file_descriptor(&self) -> &'a FileDescriptorProto { + self.get_scope().get_file_descriptor() + } + + // message or enum name + fn get_name(&self) -> &'a str; + + fn escape_prefix(&self) -> &'static str; + + fn name_to_package(&self) -> String { + let mut r = self.get_scope().prefix(); + r.push_str(self.get_name()); + r + } + + // rust type name of this descriptor + fn rust_name(&self) -> String { + let mut r = self.get_scope().rust_prefix(); + // Only escape if prefix is not empty + if r.is_empty() && rust::is_rust_keyword(self.get_name()) { + r.push_str(self.escape_prefix()); + } + r.push_str(self.get_name()); + r + } + + // fully-qualified name of this type + fn rust_fq_name(&self) -> String { + format!( + "{}::{}", + proto_path_to_rust_mod(self.get_scope().get_file_descriptor().get_name()), + self.rust_name() + ) + } +} + +#[derive(Clone)] +pub struct MessageWithScope<'a> { + pub scope: Scope<'a>, + pub message: &'a DescriptorProto, +} + + +impl<'a> WithScope<'a> for MessageWithScope<'a> { + fn get_scope(&self) -> &Scope<'a> { + &self.scope + } + + fn escape_prefix(&self) -> &'static str { + "message_" + } + + fn get_name(&self) -> &'a str { + self.message.get_name() + } +} + +impl<'a> MessageWithScope<'a> { + pub fn into_scope(mut self) -> Scope<'a> { + self.scope.path.push(self.message); + self.scope + } + + pub fn to_scope(&self) -> Scope<'a> { + self.clone().into_scope() + } + + pub fn fields(&self) -> Vec> { + self.message + .get_field() + .iter() + .map(|f| { + FieldWithContext { + field: f, + message: self.clone(), + } + }) + .collect() + } + + pub fn oneofs(&'a self) -> Vec> { + self.message + .get_oneof_decl() + .iter() + .enumerate() + .map(|(index, oneof)| { + OneofWithContext { + message: &self, + oneof: &oneof, + index: index as u32, + } + }) + .collect() + } + + pub fn oneof_by_index(&'a self, index: u32) -> OneofWithContext<'a> { + self.oneofs().swap_remove(index as usize) + } + + /// Pair of (key, value) if this message is map entry + pub fn map_entry(&'a self) -> Option<(FieldWithContext<'a>, FieldWithContext<'a>)> { + if self.message.get_options().get_map_entry() { + let key = self.fields() + .into_iter() + .find(|f| f.field.get_number() == 1) + .unwrap(); + let value = self.fields() + .into_iter() + .find(|f| f.field.get_number() == 2) + .unwrap(); + Some((key, value)) + } else { + None + } + } +} + + +#[derive(Clone)] +pub struct EnumWithScope<'a> { + pub scope: Scope<'a>, + pub en: &'a EnumDescriptorProto, +} + + +impl<'a> EnumWithScope<'a> { + // enum values + pub fn values(&'a self) -> &'a [EnumValueDescriptorProto] { + self.en.get_value() + } + + // find enum value by name + pub fn value_by_name(&'a self, name: &str) -> &'a EnumValueDescriptorProto { + self.en + .get_value() + .into_iter() + .find(|v| v.get_name() == name) + .unwrap() + } +} + +pub trait EnumValueDescriptorEx { + fn rust_name(&self) -> String; +} + +impl EnumValueDescriptorEx for EnumValueDescriptorProto { + fn rust_name(&self) -> String { + let mut r = String::new(); + if rust::is_rust_keyword(self.get_name()) { + r.push_str("value_"); + } + r.push_str(self.get_name()); + r + } +} + +impl<'a> WithScope<'a> for EnumWithScope<'a> { + fn get_scope(&self) -> &Scope<'a> { + &self.scope + } + + fn escape_prefix(&self) -> &'static str { + "enum_" + } + + fn get_name(&self) -> &'a str { + self.en.get_name() + } +} + + +pub enum MessageOrEnumWithScope<'a> { + Message(MessageWithScope<'a>), + Enum(EnumWithScope<'a>), +} + +impl<'a> WithScope<'a> for MessageOrEnumWithScope<'a> { + fn get_scope(&self) -> &Scope<'a> { + match self { + &MessageOrEnumWithScope::Message(ref m) => m.get_scope(), + &MessageOrEnumWithScope::Enum(ref e) => e.get_scope(), + } + } + + fn escape_prefix(&self) -> &'static str { + match self { + &MessageOrEnumWithScope::Message(ref m) => m.escape_prefix(), + &MessageOrEnumWithScope::Enum(ref e) => e.escape_prefix(), + } + } + + fn get_name(&self) -> &'a str { + match self { + &MessageOrEnumWithScope::Message(ref m) => m.get_name(), + &MessageOrEnumWithScope::Enum(ref e) => e.get_name(), + } + } +} + + +#[derive(Clone)] +pub struct FieldWithContext<'a> { + pub field: &'a FieldDescriptorProto, + pub message: MessageWithScope<'a>, +} + +impl<'a> FieldWithContext<'a> { + fn is_oneof(&self) -> bool { + self.field.has_oneof_index() + } + + pub fn oneof(&'a self) -> Option> { + if self.is_oneof() { + Some( + self.message + .oneof_by_index(self.field.get_oneof_index() as u32), + ) + } else { + None + } + } + + pub fn number(&self) -> u32 { + self.field.get_number() as u32 + } + + /// Shortcut + pub fn name(&self) -> &str { + self.field.get_name() + } + + // field name in generated code + pub fn rust_name(&self) -> String { + if rust::is_rust_keyword(self.field.get_name()) { + format!("field_{}", self.field.get_name()) + } else { + self.field.get_name().to_string() + } + } + + // From field to file root + pub fn containing_messages(&self) -> Vec<&'a DescriptorProto> { + let mut r = Vec::new(); + r.push(self.message.message); + r.extend(self.message.scope.path.iter().rev()); + r + } +} + + +#[derive(Clone)] +pub struct OneofVariantWithContext<'a> { + pub oneof: &'a OneofWithContext<'a>, + pub field: &'a FieldDescriptorProto, +} + + +#[derive(Clone)] +pub struct OneofWithContext<'a> { + pub oneof: &'a OneofDescriptorProto, + pub index: u32, + pub message: &'a MessageWithScope<'a>, +} + +impl<'a> OneofWithContext<'a> { + pub fn name(&'a self) -> &'a str { + match self.oneof.get_name() { + "type" => "field_type", + "box" => "field_box", + x => x, + } + } + + // rust type name of enum + pub fn rust_name(&self) -> String { + format!( + "{}_oneof_{}", + self.message.rust_name(), + self.oneof.get_name() + ) + } + + pub fn variants(&'a self) -> Vec> { + self.message + .fields() + .iter() + .filter(|f| { + f.field.has_oneof_index() && f.field.get_oneof_index() == self.index as i32 + }) + .map(|f| { + OneofVariantWithContext { + oneof: self, + field: &f.field, + } + }) + .collect() + } +} + + +// find message by rust type name +pub fn find_message_by_rust_name<'a>( + fd: &'a FileDescriptorProto, + rust_name: &str, +) -> MessageWithScope<'a> { + FileScope { file_descriptor: fd } + .find_messages() + .into_iter() + .find(|m| m.rust_name() == rust_name) + .unwrap() +} + +// find enum by rust type name +pub fn find_enum_by_rust_name<'a>( + fd: &'a FileDescriptorProto, + rust_name: &str, +) -> EnumWithScope<'a> { + FileScope { file_descriptor: fd } + .find_enums() + .into_iter() + .find(|e| e.rust_name() == rust_name) + .unwrap() +} diff --git a/third_party/protobuf/src/error.rs b/third_party/protobuf/src/error.rs new file mode 100644 index 000000000..12a8c689c --- /dev/null +++ b/third_party/protobuf/src/error.rs @@ -0,0 +1,105 @@ +use std::io; +use std::error::Error; +use std::fmt; +use std::str; +use std::boxed::Box; + +use wire_format::WireType; + +pub type ProtobufResult = Result; + +/// Enum values added here for diagnostic purposes. +/// Users should not depend on specific values. +#[derive(Debug)] +pub enum WireError { + UnexpectedEof, + UnexpectedWireType(WireType), + IncorrectTag(u32), + IncompleteMap, + IncorrectVarint, + Utf8Error, + InvalidEnumValue(i32), + Other, +} + +#[derive(Debug)] +pub enum ProtobufError { + IoError(io::Error), + WireError(WireError), + Utf8(str::Utf8Error), + MessageNotInitialized { message: &'static str }, +} + +impl ProtobufError { + pub fn message_not_initialized(message: &'static str) -> ProtobufError { + ProtobufError::MessageNotInitialized { message: message } + } +} + +impl fmt::Display for ProtobufError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(self, f) + } +} + +impl Error for ProtobufError { + fn description(&self) -> &str { + match self { + // not sure that cause should be included in message + &ProtobufError::IoError(ref e) => e.description(), + &ProtobufError::WireError(ref e) => { + match *e { + WireError::Utf8Error => "invalid UTF-8 sequence", + WireError::UnexpectedWireType(..) => "unexpected wire type", + WireError::InvalidEnumValue(..) => "invalid enum value", + WireError::IncorrectTag(..) => "incorrect tag", + WireError::IncorrectVarint => "incorrect varint", + WireError::IncompleteMap => "incomplete map", + WireError::UnexpectedEof => "unexpected EOF", + WireError::Other => "other error", + } + } + &ProtobufError::Utf8(ref e) => &e.description(), + &ProtobufError::MessageNotInitialized { .. } => "not all message fields set", + } + } + + fn cause(&self) -> Option<&Error> { + match self { + &ProtobufError::IoError(ref e) => Some(e), + &ProtobufError::Utf8(ref e) => Some(e), + &ProtobufError::WireError(..) => None, + &ProtobufError::MessageNotInitialized { .. } => None, + } + } +} + +impl From for ProtobufError { + fn from(err: io::Error) -> Self { + ProtobufError::IoError(err) + } +} + +impl From for ProtobufError { + fn from(err: str::Utf8Error) -> Self { + ProtobufError::Utf8(err) + } +} + +impl From for io::Error { + fn from(err: ProtobufError) -> Self { + match err { + ProtobufError::IoError(e) => e, + ProtobufError::WireError(e) => { + io::Error::new(io::ErrorKind::InvalidData, ProtobufError::WireError(e)) + } + ProtobufError::MessageNotInitialized { message: msg } => { + io::Error::new( + io::ErrorKind::InvalidInput, + ProtobufError::MessageNotInitialized { message: msg }, + ) + } + e => io::Error::new(io::ErrorKind::Other, Box::new(e)), + } + } +} diff --git a/third_party/protobuf/src/ext.rs b/third_party/protobuf/src/ext.rs new file mode 100644 index 000000000..18b73fd11 --- /dev/null +++ b/third_party/protobuf/src/ext.rs @@ -0,0 +1,31 @@ +use std::marker::PhantomData; +use std::vec::Vec; + +use protocore::Message; +use types::ProtobufType; + +/// Optional ext field +pub struct ExtFieldOptional { + pub field_number: u32, + pub phantom: PhantomData<(M, T)>, +} + +/// Repeated ext field +pub struct ExtFieldRepeated { + pub field_number: u32, + pub phantom: PhantomData<(M, T)>, +} + +impl ExtFieldOptional { + pub fn get(&self, m: &M) -> Option { + m.get_unknown_fields() + .get(self.field_number) + .and_then(T::get_from_unknown) + } +} + +impl ExtFieldRepeated { + pub fn get(&self, _m: &M) -> Vec { + unimplemented!() + } +} diff --git a/third_party/protobuf/src/hex.rs b/third_party/protobuf/src/hex.rs new file mode 100644 index 000000000..0c57c81c8 --- /dev/null +++ b/third_party/protobuf/src/hex.rs @@ -0,0 +1,80 @@ +// hex encoder and decoder used by rust-protobuf unittests +use std::string::String; +use std::vec::Vec; +use std::char; +use std::slice::SliceConcatExt; + +fn decode_hex_digit(digit: char) -> u8 { + match digit { + '0'...'9' => digit as u8 - '0' as u8, + 'a'...'f' => digit as u8 - 'a' as u8 + 10, + 'A'...'F' => digit as u8 - 'A' as u8 + 10, + _ => panic!(), + } +} + +pub fn decode_hex(hex: &str) -> Vec { + let mut r: Vec = Vec::new(); + let mut chars = hex.chars().enumerate(); + loop { + let (pos, first) = match chars.next() { + None => break, + Some(elt) => elt, + }; + if first == ' ' { + continue; + } + let (_, second) = match chars.next() { + None => panic!("pos = {}d", pos), + Some(elt) => elt, + }; + r.push((decode_hex_digit(first) << 4) | decode_hex_digit(second)); + } + r +} + +fn encode_hex_digit(digit: u8) -> char { + match char::from_digit(digit as u32, 16) { + Some(c) => c, + _ => panic!(), + } +} + +fn encode_hex_byte(byte: u8) -> [char; 2] { + [encode_hex_digit(byte >> 4), encode_hex_digit(byte & 0x0Fu8)] +} + +pub fn encode_hex(bytes: &[u8]) -> String { + let strs: Vec = bytes + .iter() + .map(|byte| encode_hex_byte(*byte).iter().map(|c| *c).collect()) + .collect(); + strs.join(" ") +} + +#[cfg(test)] +mod test { + + use super::decode_hex; + use super::encode_hex; + + #[test] + fn test_decode_hex() { + assert_eq!(decode_hex(""), [].to_vec()); + assert_eq!(decode_hex("00"), [0x00u8].to_vec()); + assert_eq!(decode_hex("ff"), [0xffu8].to_vec()); + assert_eq!(decode_hex("AB"), [0xabu8].to_vec()); + assert_eq!(decode_hex("fa 19"), [0xfau8, 0x19].to_vec()); + } + + #[test] + fn test_encode_hex() { + assert_eq!("".to_string(), encode_hex(&[])); + assert_eq!("00".to_string(), encode_hex(&[0x00])); + assert_eq!("ab".to_string(), encode_hex(&[0xab])); + assert_eq!( + "01 a2 1a fe".to_string(), + encode_hex(&[0x01, 0xa2, 0x1a, 0xfe]) + ); + } +} diff --git a/third_party/protobuf/src/lazy.rs b/third_party/protobuf/src/lazy.rs new file mode 100644 index 000000000..8f0d7d6bd --- /dev/null +++ b/third_party/protobuf/src/lazy.rs @@ -0,0 +1,90 @@ +use std::mem; +use std::sync; +use std::boxed::Box; + +pub struct Lazy { + pub lock: sync::Once, + pub ptr: *const T, +} + +impl Lazy { + pub fn get(&'static mut self, init: F) -> &'static T + where + F : FnOnce() -> T, + { + // ~ decouple the lifetimes of 'self' and 'self.lock' such we + // can initialize self.ptr in the call_once closure (note: we + // do have to initialize self.ptr in the closure to guarantee + // the ptr is valid for all calling threads at any point in + // time) + let lock: &sync::Once = unsafe { mem::transmute(&self.lock) }; + lock.call_once(|| unsafe { + self.ptr = mem::transmute(Box::new(init())); + }); + unsafe { &*self.ptr } + } +} + +pub const ONCE_INIT: sync::Once = sync::ONCE_INIT; + + +#[cfg(test)] +mod test { + use super::{Lazy, ONCE_INIT}; + use std::thread; + use std::sync::{Arc, Barrier}; + use std::sync::atomic::{ATOMIC_ISIZE_INIT, AtomicIsize, Ordering}; + + #[test] + fn many_threads_calling_get() { + const N_THREADS: usize = 32; + const N_ITERS_IN_THREAD: usize = 32; + const N_ITERS: usize = 16; + + static mut LAZY: Lazy = Lazy { + lock: ONCE_INIT, + ptr: 0 as *const String, + }; + static CALL_COUNT: AtomicIsize = ATOMIC_ISIZE_INIT; + + let value = "Hello, world!".to_owned(); + + for _ in 0..N_ITERS { + // Reset mutable state. + unsafe { + LAZY = Lazy { + lock: ONCE_INIT, + ptr: 0 as *const String, + } + } + CALL_COUNT.store(0, Ordering::SeqCst); + + // Create a bunch of threads, all calling .get() at the same time. + let mut threads = vec![]; + let barrier = Arc::new(Barrier::new(N_THREADS)); + + for _ in 0..N_THREADS { + let cloned_value_thread = value.clone(); + let cloned_barrier = barrier.clone(); + threads.push(thread::spawn(move || { + // Ensure all threads start at once to maximise contention. + cloned_barrier.wait(); + for _ in 0..N_ITERS_IN_THREAD { + assert_eq!(&cloned_value_thread, unsafe { + LAZY.get(|| { + CALL_COUNT.fetch_add(1, Ordering::SeqCst); + cloned_value_thread.clone() + }) + }); + } + })); + } + + for thread in threads { + thread.join().unwrap(); + } + + assert_eq!(CALL_COUNT.load(Ordering::SeqCst), 1); + } + } +} diff --git a/third_party/protobuf/src/lib.rs b/third_party/protobuf/src/lib.rs new file mode 100644 index 000000000..4f8933174 --- /dev/null +++ b/third_party/protobuf/src/lib.rs @@ -0,0 +1,115 @@ +#![crate_type = "lib"] +#![no_std] +#![feature(slice_concat_ext)] + +#![cfg_attr(target_env = "sgx", feature(rustc_private))] + +#[cfg(feature = "bytes")] +extern crate bytes; + +#[cfg(not(target_env = "sgx"))] +#[macro_use] +extern crate sgx_tstd as std; + +#[cfg(target_env = "sgx")] +#[macro_use] +extern crate std; + +pub use unknown::UnknownFields; +pub use unknown::UnknownFieldsIter; +pub use unknown::UnknownValue; +pub use unknown::UnknownValueRef; +pub use unknown::UnknownValues; +pub use unknown::UnknownValuesIter; +pub use repeated::RepeatedField; +pub use singular::SingularField; +pub use singular::SingularPtrField; +pub use clear::Clear; +pub use protocore::Message; +pub use protocore::MessageStatic; +pub use protocore::ProtobufEnum; +pub use protocore::parse_from_bytes; +pub use protocore::parse_from_reader; +#[cfg(feature = "bytes")] +pub use protocore::parse_from_carllerche_bytes; +pub use protocore::parse_length_delimited_from; +pub use protocore::parse_length_delimited_from_bytes; +pub use stream::CodedInputStream; +pub use stream::CodedOutputStream; +pub use stream::wire_format; +pub use error::ProtobufResult; +pub use error::ProtobufError; +pub use cached_size::CachedSize; +#[cfg(feature = "bytes")] +pub use chars::Chars; + +// generated +pub mod descriptor; +pub mod plugin; +mod rustproto; + +pub mod protocore; +pub mod rt; +pub mod lazy; +//pub mod code_writer; +//pub mod codegen; +pub mod compiler_plugin; +pub mod repeated; +pub mod singular; +pub mod clear; +pub mod reflect; +pub mod text_format; +pub mod stream; +pub mod error; +pub mod types; +pub mod well_known_types; +pub mod ext; + +// used by test +pub mod hex; + +// used by rust-grpc +pub mod descriptorx; + +mod zigzag; +mod paginate; +mod unknown; +mod strx; +mod rust; +mod cached_size; +mod varint; +#[cfg(feature = "bytes")] +pub mod chars; // TODO: make private + +mod misc; + +mod buf_read_iter; + + +// so `use protobuf::*` could work in mod descriptor and well_known_types +mod protobuf { + pub use descriptor; + pub use descriptorx; +// pub use codegen; + pub use reflect; + pub use protocore::*; + pub use error::*; + pub use stream::*; + pub use rt; + pub use text_format; + pub use types; + pub use lazy; + pub use well_known_types; + pub use ext; + pub use unknown::UnknownFields; + pub use unknown::UnknownFieldsIter; + pub use unknown::UnknownValue; + pub use unknown::UnknownValueRef; + pub use unknown::UnknownValues; + pub use unknown::UnknownValuesIter; + pub use repeated::RepeatedField; + pub use singular::SingularField; + pub use singular::SingularPtrField; + pub use clear::Clear; + pub use cached_size::CachedSize; +} diff --git a/third_party/protobuf/src/misc.rs b/third_party/protobuf/src/misc.rs new file mode 100644 index 000000000..7e050401e --- /dev/null +++ b/third_party/protobuf/src/misc.rs @@ -0,0 +1,38 @@ +use std::slice; +use std::mem; +use std::vec::Vec; + +/// Slice from `vec[vec.len()..vec.capacity()]` +pub unsafe fn remaining_capacity_as_slice_mut(vec: &mut Vec) -> &mut [A] { + slice::from_raw_parts_mut( + vec.as_mut_slice().as_mut_ptr().offset(vec.len() as isize), + vec.capacity() - vec.len(), + ) +} + +pub unsafe fn remove_lifetime_mut(a: &mut A) -> &'static mut A { + mem::transmute(a) +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_remaining_capacity_as_slice_mut() { + let mut v = Vec::with_capacity(5); + v.push(10); + v.push(11); + v.push(12); + unsafe { + { + let s = remaining_capacity_as_slice_mut(&mut v); + assert_eq!(2, s.len()); + s[0] = 13; + s[1] = 14; + } + v.set_len(5); + } + assert_eq!(vec![10, 11, 12, 13, 14], v); + } +} diff --git a/third_party/protobuf/src/paginate.rs b/third_party/protobuf/src/paginate.rs new file mode 100644 index 000000000..a43c085ce --- /dev/null +++ b/third_party/protobuf/src/paginate.rs @@ -0,0 +1,35 @@ +use std::vec::Vec; + +pub trait PaginatableIterator: Sized { + fn paginate(self, page: usize) -> Paginate; +} + +impl> PaginatableIterator for U { + fn paginate(self, page: usize) -> Paginate { + Paginate { + iter: self, + page: page, + } + } +} + +pub struct Paginate { + iter: I, + page: usize, +} + +impl> Iterator for Paginate { + type Item = Vec; + + fn next(&mut self) -> Option> { + let mut r = Vec::new(); + for _ in 0..self.page { + match self.iter.next() { + Some(next) => r.push(next), + None if r.is_empty() => return None, + None => return Some(r), + } + } + Some(r) + } +} diff --git a/third_party/protobuf/src/plugin.rs b/third_party/protobuf/src/plugin.rs new file mode 100644 index 000000000..e90b28241 --- /dev/null +++ b/third_party/protobuf/src/plugin.rs @@ -0,0 +1,1080 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] +use std::boxed::Box; + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +#[derive(PartialEq,Clone,Default)] +pub struct CodeGeneratorRequest { + // message fields + file_to_generate: ::protobuf::RepeatedField<::std::string::String>, + parameter: ::protobuf::SingularField<::std::string::String>, + proto_file: ::protobuf::RepeatedField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for CodeGeneratorRequest {} + +impl CodeGeneratorRequest { + pub fn new() -> CodeGeneratorRequest { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static CodeGeneratorRequest { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const CodeGeneratorRequest, + }; + unsafe { + instance.get(CodeGeneratorRequest::new) + } + } + + // repeated string file_to_generate = 1; + + pub fn clear_file_to_generate(&mut self) { + self.file_to_generate.clear(); + } + + // Param is passed by value, moved + pub fn set_file_to_generate(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { + self.file_to_generate = v; + } + + // Mutable pointer to the field. + pub fn mut_file_to_generate(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.file_to_generate + } + + // Take field + pub fn take_file_to_generate(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { + ::std::mem::replace(&mut self.file_to_generate, ::protobuf::RepeatedField::new()) + } + + pub fn get_file_to_generate(&self) -> &[::std::string::String] { + &self.file_to_generate + } + + fn get_file_to_generate_for_reflect(&self) -> &::protobuf::RepeatedField<::std::string::String> { + &self.file_to_generate + } + + fn mut_file_to_generate_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.file_to_generate + } + + // optional string parameter = 2; + + pub fn clear_parameter(&mut self) { + self.parameter.clear(); + } + + pub fn has_parameter(&self) -> bool { + self.parameter.is_some() + } + + // Param is passed by value, moved + pub fn set_parameter(&mut self, v: ::std::string::String) { + self.parameter = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_parameter(&mut self) -> &mut ::std::string::String { + if self.parameter.is_none() { + self.parameter.set_default(); + } + self.parameter.as_mut().unwrap() + } + + // Take field + pub fn take_parameter(&mut self) -> ::std::string::String { + self.parameter.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_parameter(&self) -> &str { + match self.parameter.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_parameter_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.parameter + } + + fn mut_parameter_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.parameter + } + + // repeated .google.protobuf.FileDescriptorProto proto_file = 15; + + pub fn clear_proto_file(&mut self) { + self.proto_file.clear(); + } + + // Param is passed by value, moved + pub fn set_proto_file(&mut self, v: ::protobuf::RepeatedField) { + self.proto_file = v; + } + + // Mutable pointer to the field. + pub fn mut_proto_file(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.proto_file + } + + // Take field + pub fn take_proto_file(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.proto_file, ::protobuf::RepeatedField::new()) + } + + pub fn get_proto_file(&self) -> &[super::descriptor::FileDescriptorProto] { + &self.proto_file + } + + fn get_proto_file_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.proto_file + } + + fn mut_proto_file_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.proto_file + } +} + +impl ::protobuf::Message for CodeGeneratorRequest { + fn is_initialized(&self) -> bool { + for v in &self.proto_file { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.file_to_generate)?; + }, + 2 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.parameter)?; + }, + 15 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.proto_file)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + for value in &self.file_to_generate { + my_size += ::protobuf::rt::string_size(1, &value); + }; + if let Some(ref v) = self.parameter.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + for value in &self.proto_file { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + for v in &self.file_to_generate { + os.write_string(1, &v)?; + }; + if let Some(ref v) = self.parameter.as_ref() { + os.write_string(2, &v)?; + } + for v in &self.proto_file { + os.write_tag(15, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for CodeGeneratorRequest { + fn new() -> CodeGeneratorRequest { + CodeGeneratorRequest::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "file_to_generate", + CodeGeneratorRequest::get_file_to_generate_for_reflect, + CodeGeneratorRequest::mut_file_to_generate_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "parameter", + CodeGeneratorRequest::get_parameter_for_reflect, + CodeGeneratorRequest::mut_parameter_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "proto_file", + CodeGeneratorRequest::get_proto_file_for_reflect, + CodeGeneratorRequest::mut_proto_file_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "CodeGeneratorRequest", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for CodeGeneratorRequest { + fn clear(&mut self) { + self.clear_file_to_generate(); + self.clear_parameter(); + self.clear_proto_file(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for CodeGeneratorRequest { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for CodeGeneratorRequest { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct CodeGeneratorResponse { + // message fields + error: ::protobuf::SingularField<::std::string::String>, + file: ::protobuf::RepeatedField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for CodeGeneratorResponse {} + +impl CodeGeneratorResponse { + pub fn new() -> CodeGeneratorResponse { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static CodeGeneratorResponse { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const CodeGeneratorResponse, + }; + unsafe { + instance.get(CodeGeneratorResponse::new) + } + } + + // optional string error = 1; + + pub fn clear_error(&mut self) { + self.error.clear(); + } + + pub fn has_error(&self) -> bool { + self.error.is_some() + } + + // Param is passed by value, moved + pub fn set_error(&mut self, v: ::std::string::String) { + self.error = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_error(&mut self) -> &mut ::std::string::String { + if self.error.is_none() { + self.error.set_default(); + } + self.error.as_mut().unwrap() + } + + // Take field + pub fn take_error(&mut self) -> ::std::string::String { + self.error.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_error(&self) -> &str { + match self.error.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_error_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.error + } + + fn mut_error_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.error + } + + // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15; + + pub fn clear_file(&mut self) { + self.file.clear(); + } + + // Param is passed by value, moved + pub fn set_file(&mut self, v: ::protobuf::RepeatedField) { + self.file = v; + } + + // Mutable pointer to the field. + pub fn mut_file(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.file + } + + // Take field + pub fn take_file(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.file, ::protobuf::RepeatedField::new()) + } + + pub fn get_file(&self) -> &[CodeGeneratorResponse_File] { + &self.file + } + + fn get_file_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.file + } + + fn mut_file_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.file + } +} + +impl ::protobuf::Message for CodeGeneratorResponse { + fn is_initialized(&self) -> bool { + for v in &self.file { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.error)?; + }, + 15 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.file)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.error.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + for value in &self.file { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.error.as_ref() { + os.write_string(1, &v)?; + } + for v in &self.file { + os.write_tag(15, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for CodeGeneratorResponse { + fn new() -> CodeGeneratorResponse { + CodeGeneratorResponse::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "error", + CodeGeneratorResponse::get_error_for_reflect, + CodeGeneratorResponse::mut_error_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "file", + CodeGeneratorResponse::get_file_for_reflect, + CodeGeneratorResponse::mut_file_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "CodeGeneratorResponse", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for CodeGeneratorResponse { + fn clear(&mut self) { + self.clear_error(); + self.clear_file(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for CodeGeneratorResponse { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for CodeGeneratorResponse { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct CodeGeneratorResponse_File { + // message fields + name: ::protobuf::SingularField<::std::string::String>, + insertion_point: ::protobuf::SingularField<::std::string::String>, + content: ::protobuf::SingularField<::std::string::String>, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for CodeGeneratorResponse_File {} + +impl CodeGeneratorResponse_File { + pub fn new() -> CodeGeneratorResponse_File { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static CodeGeneratorResponse_File { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const CodeGeneratorResponse_File, + }; + unsafe { + instance.get(CodeGeneratorResponse_File::new) + } + } + + // optional string name = 1; + + pub fn clear_name(&mut self) { + self.name.clear(); + } + + pub fn has_name(&self) -> bool { + self.name.is_some() + } + + // Param is passed by value, moved + pub fn set_name(&mut self, v: ::std::string::String) { + self.name = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_name(&mut self) -> &mut ::std::string::String { + if self.name.is_none() { + self.name.set_default(); + } + self.name.as_mut().unwrap() + } + + // Take field + pub fn take_name(&mut self) -> ::std::string::String { + self.name.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_name(&self) -> &str { + match self.name.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_name_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.name + } + + fn mut_name_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.name + } + + // optional string insertion_point = 2; + + pub fn clear_insertion_point(&mut self) { + self.insertion_point.clear(); + } + + pub fn has_insertion_point(&self) -> bool { + self.insertion_point.is_some() + } + + // Param is passed by value, moved + pub fn set_insertion_point(&mut self, v: ::std::string::String) { + self.insertion_point = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_insertion_point(&mut self) -> &mut ::std::string::String { + if self.insertion_point.is_none() { + self.insertion_point.set_default(); + } + self.insertion_point.as_mut().unwrap() + } + + // Take field + pub fn take_insertion_point(&mut self) -> ::std::string::String { + self.insertion_point.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_insertion_point(&self) -> &str { + match self.insertion_point.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_insertion_point_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.insertion_point + } + + fn mut_insertion_point_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.insertion_point + } + + // optional string content = 15; + + pub fn clear_content(&mut self) { + self.content.clear(); + } + + pub fn has_content(&self) -> bool { + self.content.is_some() + } + + // Param is passed by value, moved + pub fn set_content(&mut self, v: ::std::string::String) { + self.content = ::protobuf::SingularField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_content(&mut self) -> &mut ::std::string::String { + if self.content.is_none() { + self.content.set_default(); + } + self.content.as_mut().unwrap() + } + + // Take field + pub fn take_content(&mut self) -> ::std::string::String { + self.content.take().unwrap_or_else(|| ::std::string::String::new()) + } + + pub fn get_content(&self) -> &str { + match self.content.as_ref() { + Some(v) => &v, + None => "", + } + } + + fn get_content_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { + &self.content + } + + fn mut_content_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { + &mut self.content + } +} + +impl ::protobuf::Message for CodeGeneratorResponse_File { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.name)?; + }, + 2 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.insertion_point)?; + }, + 15 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.content)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(ref v) = self.name.as_ref() { + my_size += ::protobuf::rt::string_size(1, &v); + } + if let Some(ref v) = self.insertion_point.as_ref() { + my_size += ::protobuf::rt::string_size(2, &v); + } + if let Some(ref v) = self.content.as_ref() { + my_size += ::protobuf::rt::string_size(15, &v); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.name.as_ref() { + os.write_string(1, &v)?; + } + if let Some(ref v) = self.insertion_point.as_ref() { + os.write_string(2, &v)?; + } + if let Some(ref v) = self.content.as_ref() { + os.write_string(15, &v)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for CodeGeneratorResponse_File { + fn new() -> CodeGeneratorResponse_File { + CodeGeneratorResponse_File::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "name", + CodeGeneratorResponse_File::get_name_for_reflect, + CodeGeneratorResponse_File::mut_name_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "insertion_point", + CodeGeneratorResponse_File::get_insertion_point_for_reflect, + CodeGeneratorResponse_File::mut_insertion_point_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "content", + CodeGeneratorResponse_File::get_content_for_reflect, + CodeGeneratorResponse_File::mut_content_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "CodeGeneratorResponse_File", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for CodeGeneratorResponse_File { + fn clear(&mut self) { + self.clear_name(); + self.clear_insertion_point(); + self.clear_content(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for CodeGeneratorResponse_File { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for CodeGeneratorResponse_File { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n%google/protobuf/compiler/plugin.proto\x12\x18google.protobuf.compiler\ + \x1a\x20google/protobuf/descriptor.proto\"\xa3\x01\n\x14CodeGeneratorReq\ + uest\x12(\n\x10file_to_generate\x18\x01\x20\x03(\tR\x0efileToGenerate\ + \x12\x1c\n\tparameter\x18\x02\x20\x01(\tR\tparameter\x12C\n\nproto_file\ + \x18\x0f\x20\x03(\x0b2$.google.protobuf.FileDescriptorProtoR\tprotoFile\ + \"\xd6\x01\n\x15CodeGeneratorResponse\x12\x14\n\x05error\x18\x01\x20\x01\ + (\tR\x05error\x12H\n\x04file\x18\x0f\x20\x03(\x0b24.google.protobuf.comp\ + iler.CodeGeneratorResponse.FileR\x04file\x1a]\n\x04File\x12\x12\n\x04nam\ + e\x18\x01\x20\x01(\tR\x04name\x12'\n\x0finsertion_point\x18\x02\x20\x01(\ + \tR\x0einsertionPoint\x12\x18\n\x07content\x18\x0f\x20\x01(\tR\x07conten\ + tB7\n\x1ccom.google.protobuf.compilerB\x0cPluginProtosZ\tplugin_goJ\x89;\ + \n\x07\x12\x05.\0\x95\x01\x01\n\xca\x11\n\x01\x0c\x12\x03.\0\x122\xc1\ + \x0c\x20Protocol\x20Buffers\x20-\x20Google's\x20data\x20interchange\x20f\ + ormat\n\x20Copyright\x202008\x20Google\x20Inc.\x20\x20All\x20rights\x20r\ + eserved.\n\x20https://developers.google.com/protocol-buffers/\n\n\x20Red\ + istribution\x20and\x20use\x20in\x20source\x20and\x20binary\x20forms,\x20\ + with\x20or\x20without\n\x20modification,\x20are\x20permitted\x20provided\ + \x20that\x20the\x20following\x20conditions\x20are\n\x20met:\n\n\x20\x20\ + \x20\x20\x20*\x20Redistributions\x20of\x20source\x20code\x20must\x20reta\ + in\x20the\x20above\x20copyright\n\x20notice,\x20this\x20list\x20of\x20co\ + nditions\x20and\x20the\x20following\x20disclaimer.\n\x20\x20\x20\x20\x20\ + *\x20Redistributions\x20in\x20binary\x20form\x20must\x20reproduce\x20the\ + \x20above\n\x20copyright\x20notice,\x20this\x20list\x20of\x20conditions\ + \x20and\x20the\x20following\x20disclaimer\n\x20in\x20the\x20documentatio\ + n\x20and/or\x20other\x20materials\x20provided\x20with\x20the\n\x20distri\ + bution.\n\x20\x20\x20\x20\x20*\x20Neither\x20the\x20name\x20of\x20Google\ + \x20Inc.\x20nor\x20the\x20names\x20of\x20its\n\x20contributors\x20may\ + \x20be\x20used\x20to\x20endorse\x20or\x20promote\x20products\x20derived\ + \x20from\n\x20this\x20software\x20without\x20specific\x20prior\x20writte\ + n\x20permission.\n\n\x20THIS\x20SOFTWARE\x20IS\x20PROVIDED\x20BY\x20THE\ + \x20COPYRIGHT\x20HOLDERS\x20AND\x20CONTRIBUTORS\n\x20\"AS\x20IS\"\x20AND\ + \x20ANY\x20EXPRESS\x20OR\x20IMPLIED\x20WARRANTIES,\x20INCLUDING,\x20BUT\ + \x20NOT\n\x20LIMITED\x20TO,\x20THE\x20IMPLIED\x20WARRANTIES\x20OF\x20MER\ + CHANTABILITY\x20AND\x20FITNESS\x20FOR\n\x20A\x20PARTICULAR\x20PURPOSE\ + \x20ARE\x20DISCLAIMED.\x20IN\x20NO\x20EVENT\x20SHALL\x20THE\x20COPYRIGHT\ + \n\x20OWNER\x20OR\x20CONTRIBUTORS\x20BE\x20LIABLE\x20FOR\x20ANY\x20DIREC\ + T,\x20INDIRECT,\x20INCIDENTAL,\n\x20SPECIAL,\x20EXEMPLARY,\x20OR\x20CONS\ + EQUENTIAL\x20DAMAGES\x20(INCLUDING,\x20BUT\x20NOT\n\x20LIMITED\x20TO,\ + \x20PROCUREMENT\x20OF\x20SUBSTITUTE\x20GOODS\x20OR\x20SERVICES;\x20LOSS\ + \x20OF\x20USE,\n\x20DATA,\x20OR\x20PROFITS;\x20OR\x20BUSINESS\x20INTERRU\ + PTION)\x20HOWEVER\x20CAUSED\x20AND\x20ON\x20ANY\n\x20THEORY\x20OF\x20LIA\ + BILITY,\x20WHETHER\x20IN\x20CONTRACT,\x20STRICT\x20LIABILITY,\x20OR\x20T\ + ORT\n\x20(INCLUDING\x20NEGLIGENCE\x20OR\x20OTHERWISE)\x20ARISING\x20IN\ + \x20ANY\x20WAY\x20OUT\x20OF\x20THE\x20USE\n\x20OF\x20THIS\x20SOFTWARE,\ + \x20EVEN\x20IF\x20ADVISED\x20OF\x20THE\x20POSSIBILITY\x20OF\x20SUCH\x20D\ + AMAGE.\n2\xfb\x04\x20Author:\x20kenton@google.com\x20(Kenton\x20Varda)\n\ + \n\x20WARNING:\x20\x20The\x20plugin\x20interface\x20is\x20currently\x20E\ + XPERIMENTAL\x20and\x20is\x20subject\x20to\n\x20\x20\x20change.\n\n\x20pr\ + otoc\x20(aka\x20the\x20Protocol\x20Compiler)\x20can\x20be\x20extended\ + \x20via\x20plugins.\x20\x20A\x20plugin\x20is\n\x20just\x20a\x20program\ + \x20that\x20reads\x20a\x20CodeGeneratorRequest\x20from\x20stdin\x20and\ + \x20writes\x20a\n\x20CodeGeneratorResponse\x20to\x20stdout.\n\n\x20Plugi\ + ns\x20written\x20using\x20C++\x20can\x20use\x20google/protobuf/compiler/\ + plugin.h\x20instead\n\x20of\x20dealing\x20with\x20the\x20raw\x20protocol\ + \x20defined\x20here.\n\n\x20A\x20plugin\x20executable\x20needs\x20only\ + \x20to\x20be\x20placed\x20somewhere\x20in\x20the\x20path.\x20\x20The\n\ + \x20plugin\x20should\x20be\x20named\x20\"protoc-gen-$NAME\",\x20and\x20w\ + ill\x20then\x20be\x20used\x20when\x20the\n\x20flag\x20\"--${NAME}_out\"\ + \x20is\x20passed\x20to\x20protoc.\n\n\x08\n\x01\x02\x12\x03/\x08\x20\n\ + \x08\n\x01\x08\x12\x030\05\n\x0b\n\x04\x08\xe7\x07\0\x12\x030\05\n\x0c\n\ + \x05\x08\xe7\x07\0\x02\x12\x030\x07\x13\n\r\n\x06\x08\xe7\x07\0\x02\0\ + \x12\x030\x07\x13\n\x0e\n\x07\x08\xe7\x07\0\x02\0\x01\x12\x030\x07\x13\n\ + \x0c\n\x05\x08\xe7\x07\0\x07\x12\x030\x164\n\x08\n\x01\x08\x12\x031\0-\n\ + \x0b\n\x04\x08\xe7\x07\x01\x12\x031\0-\n\x0c\n\x05\x08\xe7\x07\x01\x02\ + \x12\x031\x07\x1b\n\r\n\x06\x08\xe7\x07\x01\x02\0\x12\x031\x07\x1b\n\x0e\ + \n\x07\x08\xe7\x07\x01\x02\0\x01\x12\x031\x07\x1b\n\x0c\n\x05\x08\xe7\ + \x07\x01\x07\x12\x031\x1e,\n\x08\n\x01\x08\x12\x033\0\x20\n\x0b\n\x04\ + \x08\xe7\x07\x02\x12\x033\0\x20\n\x0c\n\x05\x08\xe7\x07\x02\x02\x12\x033\ + \x07\x11\n\r\n\x06\x08\xe7\x07\x02\x02\0\x12\x033\x07\x11\n\x0e\n\x07\ + \x08\xe7\x07\x02\x02\0\x01\x12\x033\x07\x11\n\x0c\n\x05\x08\xe7\x07\x02\ + \x07\x12\x033\x14\x1f\n\t\n\x02\x03\0\x12\x035\x07)\nO\n\x02\x04\0\x12\ + \x048\0M\x01\x1aC\x20An\x20encoded\x20CodeGeneratorRequest\x20is\x20writ\ + ten\x20to\x20the\x20plugin's\x20stdin.\n\n\n\n\x03\x04\0\x01\x12\x038\ + \x08\x1c\n\xd1\x01\n\x04\x04\0\x02\0\x12\x03<\x02'\x1a\xc3\x01\x20The\ + \x20.proto\x20files\x20that\x20were\x20explicitly\x20listed\x20on\x20the\ + \x20command-line.\x20\x20The\n\x20code\x20generator\x20should\x20generat\ + e\x20code\x20only\x20for\x20these\x20files.\x20\x20Each\x20file's\n\x20d\ + escriptor\x20will\x20be\x20included\x20in\x20proto_file,\x20below.\n\n\ + \x0c\n\x05\x04\0\x02\0\x04\x12\x03<\x02\n\n\x0c\n\x05\x04\0\x02\0\x05\ + \x12\x03<\x0b\x11\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03<\x12\"\n\x0c\n\x05\ + \x04\0\x02\0\x03\x12\x03<%&\nB\n\x04\x04\0\x02\x01\x12\x03?\x02\x20\x1a5\ + \x20The\x20generator\x20parameter\x20passed\x20on\x20the\x20command-line\ + .\n\n\x0c\n\x05\x04\0\x02\x01\x04\x12\x03?\x02\n\n\x0c\n\x05\x04\0\x02\ + \x01\x05\x12\x03?\x0b\x11\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03?\x12\x1b\ + \n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03?\x1e\x1f\n\xa9\x05\n\x04\x04\0\ + \x02\x02\x12\x03L\x02/\x1a\x9b\x05\x20FileDescriptorProtos\x20for\x20all\ + \x20files\x20in\x20files_to_generate\x20and\x20everything\n\x20they\x20i\ + mport.\x20\x20The\x20files\x20will\x20appear\x20in\x20topological\x20ord\ + er,\x20so\x20each\x20file\n\x20appears\x20before\x20any\x20file\x20that\ + \x20imports\x20it.\n\n\x20protoc\x20guarantees\x20that\x20all\x20proto_f\ + iles\x20will\x20be\x20written\x20after\n\x20the\x20fields\x20above,\x20e\ + ven\x20though\x20this\x20is\x20not\x20technically\x20guaranteed\x20by\ + \x20the\n\x20protobuf\x20wire\x20format.\x20\x20This\x20theoretically\ + \x20could\x20allow\x20a\x20plugin\x20to\x20stream\n\x20in\x20the\x20File\ + DescriptorProtos\x20and\x20handle\x20them\x20one\x20by\x20one\x20rather\ + \x20than\x20read\n\x20the\x20entire\x20set\x20into\x20memory\x20at\x20on\ + ce.\x20\x20However,\x20as\x20of\x20this\x20writing,\x20this\n\x20is\x20n\ + ot\x20similarly\x20optimized\x20on\x20protoc's\x20end\x20--\x20it\x20wil\ + l\x20store\x20all\x20fields\x20in\n\x20memory\x20at\x20once\x20before\ + \x20sending\x20them\x20to\x20the\x20plugin.\n\n\x0c\n\x05\x04\0\x02\x02\ + \x04\x12\x03L\x02\n\n\x0c\n\x05\x04\0\x02\x02\x06\x12\x03L\x0b\x1e\n\x0c\ + \n\x05\x04\0\x02\x02\x01\x12\x03L\x1f)\n\x0c\n\x05\x04\0\x02\x02\x03\x12\ + \x03L,.\nL\n\x02\x04\x01\x12\x05P\0\x95\x01\x01\x1a?\x20The\x20plugin\ + \x20writes\x20an\x20encoded\x20CodeGeneratorResponse\x20to\x20stdout.\n\ + \n\n\n\x03\x04\x01\x01\x12\x03P\x08\x1d\n\xed\x03\n\x04\x04\x01\x02\0\ + \x12\x03Y\x02\x1c\x1a\xdf\x03\x20Error\x20message.\x20\x20If\x20non-empt\ + y,\x20code\x20generation\x20failed.\x20\x20The\x20plugin\x20process\n\ + \x20should\x20exit\x20with\x20status\x20code\x20zero\x20even\x20if\x20it\ + \x20reports\x20an\x20error\x20in\x20this\x20way.\n\n\x20This\x20should\ + \x20be\x20used\x20to\x20indicate\x20errors\x20in\x20.proto\x20files\x20w\ + hich\x20prevent\x20the\n\x20code\x20generator\x20from\x20generating\x20c\ + orrect\x20code.\x20\x20Errors\x20which\x20indicate\x20a\n\x20problem\x20\ + in\x20protoc\x20itself\x20--\x20such\x20as\x20the\x20input\x20CodeGenera\ + torRequest\x20being\n\x20unparseable\x20--\x20should\x20be\x20reported\ + \x20by\x20writing\x20a\x20message\x20to\x20stderr\x20and\n\x20exiting\ + \x20with\x20a\x20non-zero\x20status\x20code.\n\n\x0c\n\x05\x04\x01\x02\0\ + \x04\x12\x03Y\x02\n\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03Y\x0b\x11\n\x0c\ + \n\x05\x04\x01\x02\0\x01\x12\x03Y\x12\x17\n\x0c\n\x05\x04\x01\x02\0\x03\ + \x12\x03Y\x1a\x1b\n4\n\x04\x04\x01\x03\0\x12\x05\\\x02\x93\x01\x03\x1a%\ + \x20Represents\x20a\x20single\x20generated\x20file.\n\n\x0c\n\x05\x04\ + \x01\x03\0\x01\x12\x03\\\n\x0e\n\xad\x05\n\x06\x04\x01\x03\0\x02\0\x12\ + \x03h\x04\x1d\x1a\x9d\x05\x20The\x20file\x20name,\x20relative\x20to\x20t\ + he\x20output\x20directory.\x20\x20The\x20name\x20must\x20not\n\x20contai\ + n\x20\".\"\x20or\x20\"..\"\x20components\x20and\x20must\x20be\x20relativ\ + e,\x20not\x20be\x20absolute\x20(so,\n\x20the\x20file\x20cannot\x20lie\ + \x20outside\x20the\x20output\x20directory).\x20\x20\"/\"\x20must\x20be\ + \x20used\x20as\n\x20the\x20path\x20separator,\x20not\x20\"\\\".\n\n\x20I\ + f\x20the\x20name\x20is\x20omitted,\x20the\x20content\x20will\x20be\x20ap\ + pended\x20to\x20the\x20previous\n\x20file.\x20\x20This\x20allows\x20the\ + \x20generator\x20to\x20break\x20large\x20files\x20into\x20small\x20chunk\ + s,\n\x20and\x20allows\x20the\x20generated\x20text\x20to\x20be\x20streame\ + d\x20back\x20to\x20protoc\x20so\x20that\x20large\n\x20files\x20need\x20n\ + ot\x20reside\x20completely\x20in\x20memory\x20at\x20one\x20time.\x20\x20\ + Note\x20that\x20as\x20of\n\x20this\x20writing\x20protoc\x20does\x20not\ + \x20optimize\x20for\x20this\x20--\x20it\x20will\x20read\x20the\x20entire\ + \n\x20CodeGeneratorResponse\x20before\x20writing\x20files\x20to\x20disk.\ + \n\n\x0e\n\x07\x04\x01\x03\0\x02\0\x04\x12\x03h\x04\x0c\n\x0e\n\x07\x04\ + \x01\x03\0\x02\0\x05\x12\x03h\r\x13\n\x0e\n\x07\x04\x01\x03\0\x02\0\x01\ + \x12\x03h\x14\x18\n\x0e\n\x07\x04\x01\x03\0\x02\0\x03\x12\x03h\x1b\x1c\n\ + \xae\x10\n\x06\x04\x01\x03\0\x02\x01\x12\x04\x8f\x01\x04(\x1a\x9d\x10\ + \x20If\x20non-empty,\x20indicates\x20that\x20the\x20named\x20file\x20sho\ + uld\x20already\x20exist,\x20and\x20the\n\x20content\x20here\x20is\x20to\ + \x20be\x20inserted\x20into\x20that\x20file\x20at\x20a\x20defined\x20inse\ + rtion\n\x20point.\x20\x20This\x20feature\x20allows\x20a\x20code\x20gener\ + ator\x20to\x20extend\x20the\x20output\n\x20produced\x20by\x20another\x20\ + code\x20generator.\x20\x20The\x20original\x20generator\x20may\x20provide\ + \n\x20insertion\x20points\x20by\x20placing\x20special\x20annotations\x20\ + in\x20the\x20file\x20that\x20look\n\x20like:\n\x20\x20\x20@@protoc_inser\ + tion_point(NAME)\n\x20The\x20annotation\x20can\x20have\x20arbitrary\x20t\ + ext\x20before\x20and\x20after\x20it\x20on\x20the\x20line,\n\x20which\x20\ + allows\x20it\x20to\x20be\x20placed\x20in\x20a\x20comment.\x20\x20NAME\ + \x20should\x20be\x20replaced\x20with\n\x20an\x20identifier\x20naming\x20\ + the\x20point\x20--\x20this\x20is\x20what\x20other\x20generators\x20will\ + \x20use\n\x20as\x20the\x20insertion_point.\x20\x20Code\x20inserted\x20at\ + \x20this\x20point\x20will\x20be\x20placed\n\x20immediately\x20above\x20t\ + he\x20line\x20containing\x20the\x20insertion\x20point\x20(thus\x20multip\ + le\n\x20insertions\x20to\x20the\x20same\x20point\x20will\x20come\x20out\ + \x20in\x20the\x20order\x20they\x20were\x20added).\n\x20The\x20double-@\ + \x20is\x20intended\x20to\x20make\x20it\x20unlikely\x20that\x20the\x20gen\ + erated\x20code\n\x20could\x20contain\x20things\x20that\x20look\x20like\ + \x20insertion\x20points\x20by\x20accident.\n\n\x20For\x20example,\x20the\ + \x20C++\x20code\x20generator\x20places\x20the\x20following\x20line\x20in\ + \x20the\n\x20.pb.h\x20files\x20that\x20it\x20generates:\n\x20\x20\x20//\ + \x20@@protoc_insertion_point(namespace_scope)\n\x20This\x20line\x20appea\ + rs\x20within\x20the\x20scope\x20of\x20the\x20file's\x20package\x20namesp\ + ace,\x20but\n\x20outside\x20of\x20any\x20particular\x20class.\x20\x20Ano\ + ther\x20plugin\x20can\x20then\x20specify\x20the\n\x20insertion_point\x20\ + \"namespace_scope\"\x20to\x20generate\x20additional\x20classes\x20or\n\ + \x20other\x20declarations\x20that\x20should\x20be\x20placed\x20in\x20thi\ + s\x20scope.\n\n\x20Note\x20that\x20if\x20the\x20line\x20containing\x20th\ + e\x20insertion\x20point\x20begins\x20with\n\x20whitespace,\x20the\x20sam\ + e\x20whitespace\x20will\x20be\x20added\x20to\x20every\x20line\x20of\x20t\ + he\n\x20inserted\x20text.\x20\x20This\x20is\x20useful\x20for\x20language\ + s\x20like\x20Python,\x20where\n\x20indentation\x20matters.\x20\x20In\x20\ + these\x20languages,\x20the\x20insertion\x20point\x20comment\n\x20should\ + \x20be\x20indented\x20the\x20same\x20amount\x20as\x20any\x20inserted\x20\ + code\x20will\x20need\x20to\x20be\n\x20in\x20order\x20to\x20work\x20corre\ + ctly\x20in\x20that\x20context.\n\n\x20The\x20code\x20generator\x20that\ + \x20generates\x20the\x20initial\x20file\x20and\x20the\x20one\x20which\n\ + \x20inserts\x20into\x20it\x20must\x20both\x20run\x20as\x20part\x20of\x20\ + a\x20single\x20invocation\x20of\x20protoc.\n\x20Code\x20generators\x20ar\ + e\x20executed\x20in\x20the\x20order\x20in\x20which\x20they\x20appear\x20\ + on\x20the\n\x20command\x20line.\n\n\x20If\x20|insertion_point|\x20is\x20\ + present,\x20|name|\x20must\x20also\x20be\x20present.\n\n\x0f\n\x07\x04\ + \x01\x03\0\x02\x01\x04\x12\x04\x8f\x01\x04\x0c\n\x0f\n\x07\x04\x01\x03\0\ + \x02\x01\x05\x12\x04\x8f\x01\r\x13\n\x0f\n\x07\x04\x01\x03\0\x02\x01\x01\ + \x12\x04\x8f\x01\x14#\n\x0f\n\x07\x04\x01\x03\0\x02\x01\x03\x12\x04\x8f\ + \x01&'\n$\n\x06\x04\x01\x03\0\x02\x02\x12\x04\x92\x01\x04!\x1a\x14\x20Th\ + e\x20file\x20contents.\n\n\x0f\n\x07\x04\x01\x03\0\x02\x02\x04\x12\x04\ + \x92\x01\x04\x0c\n\x0f\n\x07\x04\x01\x03\0\x02\x02\x05\x12\x04\x92\x01\r\ + \x13\n\x0f\n\x07\x04\x01\x03\0\x02\x02\x01\x12\x04\x92\x01\x14\x1b\n\x0f\ + \n\x07\x04\x01\x03\0\x02\x02\x03\x12\x04\x92\x01\x1e\x20\n\x0c\n\x04\x04\ + \x01\x02\x01\x12\x04\x94\x01\x02\x1a\n\r\n\x05\x04\x01\x02\x01\x04\x12\ + \x04\x94\x01\x02\n\n\r\n\x05\x04\x01\x02\x01\x06\x12\x04\x94\x01\x0b\x0f\ + \n\r\n\x05\x04\x01\x02\x01\x01\x12\x04\x94\x01\x10\x14\n\r\n\x05\x04\x01\ + \x02\x01\x03\x12\x04\x94\x01\x17\x19\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/third_party/protobuf/src/protocore.rs b/third_party/protobuf/src/protocore.rs new file mode 100644 index 000000000..e1aee5c74 --- /dev/null +++ b/third_party/protobuf/src/protocore.rs @@ -0,0 +1,239 @@ +// TODO: drop all panic! + +use std::any::Any; +use std::any::TypeId; +use std::default::Default; +use std::fmt; +use std::io::Read; +use std::io::Write; + +use std::boxed::Box; +use std::vec::Vec; + +#[cfg(feature = "bytes")] +use bytes::Bytes; + +use clear::Clear; +use reflect::MessageDescriptor; +use reflect::EnumDescriptor; +use reflect::EnumValueDescriptor; +use unknown::UnknownFields; +use stream::WithCodedInputStream; +use stream::WithCodedOutputStream; +use stream::CodedInputStream; +use stream::CodedOutputStream; +use stream::with_coded_output_stream_to_bytes; +use error::ProtobufError; +use error::ProtobufResult; + + +pub trait Message: fmt::Debug + Clear + Any + Send + Sync { + // All generated Message types also implement MessageStatic. + // However, rust doesn't allow these types to be extended by + // Message. + + fn descriptor(&self) -> &'static MessageDescriptor; + + // all required fields set + fn is_initialized(&self) -> bool; + fn merge_from(&mut self, is: &mut CodedInputStream) -> ProtobufResult<()>; + + // sizes of this messages (and nested messages) must be cached + // by calling `compute_size` prior to this call + fn write_to_with_cached_sizes(&self, os: &mut CodedOutputStream) -> ProtobufResult<()>; + + // compute and cache size of this message and all nested messages + fn compute_size(&self) -> u32; + + // get size previously computed by `compute_size` + fn get_cached_size(&self) -> u32; + + fn write_to(&self, os: &mut CodedOutputStream) -> ProtobufResult<()> { + self.check_initialized()?; + + // cache sizes + self.compute_size(); + // TODO: reserve additional + self.write_to_with_cached_sizes(os)?; + + // TODO: assert we've written same number of bytes as computed + + Ok(()) + } + + fn write_length_delimited_to(&self, os: &mut CodedOutputStream) -> ProtobufResult<()> { + let size = self.compute_size(); + os.write_raw_varint32(size)?; + self.write_to_with_cached_sizes(os)?; + + // TODO: assert we've written same number of bytes as computed + + Ok(()) + } + + fn write_length_delimited_to_vec(&self, vec: &mut Vec) -> ProtobufResult<()> { + let mut os = CodedOutputStream::vec(vec); + self.write_length_delimited_to(&mut os)?; + os.flush()?; + Ok(()) + } + + fn merge_from_bytes(&mut self, bytes: &[u8]) -> ProtobufResult<()> { + let mut is = CodedInputStream::from_bytes(bytes); + self.merge_from(&mut is) + } + + fn check_initialized(&self) -> ProtobufResult<()> { + if !self.is_initialized() { + Err( + ProtobufError::message_not_initialized(self.descriptor().name()), + ) + } else { + Ok(()) + } + } + + fn write_to_writer(&self, w: &mut Write) -> ProtobufResult<()> { + w.with_coded_output_stream(|os| self.write_to(os)) + } + + fn write_to_vec(&self, v: &mut Vec) -> ProtobufResult<()> { + v.with_coded_output_stream(|os| self.write_to(os)) + } + + fn write_to_bytes(&self) -> ProtobufResult> { + self.check_initialized()?; + + let size = self.compute_size() as usize; + let mut v = Vec::with_capacity(size); + // skip zerofill + unsafe { + v.set_len(size); + } + { + let mut os = CodedOutputStream::bytes(&mut v); + self.write_to_with_cached_sizes(&mut os)?; + os.check_eof(); + } + Ok(v) + } + + fn write_length_delimited_to_writer(&self, w: &mut Write) -> ProtobufResult<()> { + w.with_coded_output_stream(|os| self.write_length_delimited_to(os)) + } + + fn write_length_delimited_to_bytes(&self) -> ProtobufResult> { + with_coded_output_stream_to_bytes(|os| self.write_length_delimited_to(os)) + } + + fn get_unknown_fields<'s>(&'s self) -> &'s UnknownFields; + fn mut_unknown_fields<'s>(&'s mut self) -> &'s mut UnknownFields; + + fn type_id(&self) -> TypeId { + TypeId::of::() + } + + fn as_any(&self) -> &Any; + + fn as_any_mut(&mut self) -> &mut Any { + panic!() + } + + fn into_any(self: Box) -> Box { + panic!() + } + + // Rust does not allow implementation of trait for trait: + // impl fmt::Debug for M { + // ... + // } +} + +// For some reason Rust doesn't allow conversion of &Foo to &Message it +// Message contains static functions. So static functions must be placed +// into separate place. +// +// See https://github.com/rust-lang/rust/commit/cd31e6ff for details. +pub trait MessageStatic: Message + Clone + Default + PartialEq { + fn new() -> Self; + + // http://stackoverflow.com/q/20342436/15018 + fn descriptor_static(_: Option) -> &'static MessageDescriptor { + panic!( + "descriptor_static is not implemented for message, \ + LITE_RUNTIME must be used" + ); + } +} + + + +pub fn message_down_cast<'a, M : Message + 'a>(m: &'a Message) -> &'a M { + m.as_any().downcast_ref::().unwrap() +} + + +pub trait ProtobufEnum: Eq + Sized + Copy + 'static { + fn value(&self) -> i32; + + fn from_i32(v: i32) -> Option; + + fn values() -> &'static [Self] { + panic!(); + } + + fn descriptor(&self) -> &'static EnumValueDescriptor { + self.enum_descriptor().value_by_number(self.value()) + } + + fn enum_descriptor(&self) -> &'static EnumDescriptor { + ProtobufEnum::enum_descriptor_static(None::) + } + + // http://stackoverflow.com/q/20342436/15018 + fn enum_descriptor_static(_: Option) -> &'static EnumDescriptor { + panic!(); + } +} + +pub fn parse_from(is: &mut CodedInputStream) -> ProtobufResult { + let mut r: M = MessageStatic::new(); + r.merge_from(is)?; + r.check_initialized()?; + Ok(r) +} + +pub fn parse_from_reader(reader: &mut Read) -> ProtobufResult { + reader.with_coded_input_stream(|is| parse_from::(is)) +} + +pub fn parse_from_bytes(bytes: &[u8]) -> ProtobufResult { + bytes.with_coded_input_stream(|is| parse_from::(is)) +} + +#[cfg(feature = "bytes")] +pub fn parse_from_carllerche_bytes( + bytes: &Bytes, +) -> ProtobufResult { + // Call trait explicitly to avoid accidental construction from `&[u8]` + WithCodedInputStream::with_coded_input_stream(bytes, |is| parse_from::(is)) +} + +pub fn parse_length_delimited_from( + is: &mut CodedInputStream, +) -> ProtobufResult { + is.read_message::() +} + +pub fn parse_length_delimited_from_reader( + r: &mut Read, +) -> ProtobufResult { + // TODO: wrong: we may read length first, and then read exact number of bytes needed + r.with_coded_input_stream(|is| is.read_message::()) +} + +pub fn parse_length_delimited_from_bytes( + bytes: &[u8], +) -> ProtobufResult { + bytes.with_coded_input_stream(|is| is.read_message::()) +} diff --git a/third_party/protobuf/src/reflect/accessor.rs b/third_party/protobuf/src/reflect/accessor.rs new file mode 100644 index 000000000..25d9f3bee --- /dev/null +++ b/third_party/protobuf/src/reflect/accessor.rs @@ -0,0 +1,1144 @@ +use std::hash::Hash; +use std::collections::HashMap; +use std::boxed::Box; +use std::string::String; +use std::vec::Vec; + +use protocore::Message; +use protocore::ProtobufEnum; +use protocore::message_down_cast; +use reflect::EnumValueDescriptor; +use types::*; + +use repeated::RepeatedField; +use singular::SingularField; +use singular::SingularPtrField; + +use super::map::ReflectMap; +use super::repeated::ReflectRepeated; +use super::repeated::ReflectRepeatedRef; +use super::repeated::ReflectRepeatedEnum; +use super::repeated::ReflectRepeatedEnumImpl; +use super::repeated::ReflectRepeatedMessage; +use super::repeated::ReflectRepeatedMessageImpl; +use super::optional::ReflectOptional; +use super::value::ProtobufValue; +use super::value::ProtobufValueRef; +use super::ReflectFieldRef; + + +/// this trait should not be used directly, use `FieldDescriptor` instead +pub trait FieldAccessor { + fn name_generic(&self) -> &'static str; + fn has_field_generic(&self, m: &Message) -> bool; + fn len_field_generic(&self, m: &Message) -> usize; + fn get_message_generic<'a>(&self, m: &'a Message) -> &'a Message; + fn get_rep_message_item_generic<'a>(&self, m: &'a Message, index: usize) -> &'a Message; + fn get_enum_generic(&self, m: &Message) -> &'static EnumValueDescriptor; + fn get_rep_enum_item_generic(&self, m: &Message, index: usize) -> &'static EnumValueDescriptor; + fn get_str_generic<'a>(&self, m: &'a Message) -> &'a str; + fn get_rep_str_generic<'a>(&self, m: &'a Message) -> &'a [String]; + fn get_bytes_generic<'a>(&self, m: &'a Message) -> &'a [u8]; + fn get_rep_bytes_generic<'a>(&self, m: &'a Message) -> &'a [Vec]; + fn get_u32_generic(&self, m: &Message) -> u32; + fn get_rep_u32_generic<'a>(&self, m: &'a Message) -> &'a [u32]; + fn get_u64_generic(&self, m: &Message) -> u64; + fn get_rep_u64_generic<'a>(&self, m: &'a Message) -> &'a [u64]; + fn get_i32_generic(&self, m: &Message) -> i32; + fn get_rep_i32_generic<'a>(&self, m: &'a Message) -> &'a [i32]; + fn get_i64_generic(&self, m: &Message) -> i64; + fn get_rep_i64_generic<'a>(&self, m: &'a Message) -> &'a [i64]; + fn get_bool_generic(&self, m: &Message) -> bool; + fn get_rep_bool_generic<'a>(&self, m: &'a Message) -> &'a [bool]; + fn get_f32_generic(&self, m: &Message) -> f32; + fn get_rep_f32_generic<'a>(&self, m: &'a Message) -> &'a [f32]; + fn get_f64_generic(&self, m: &Message) -> f64; + fn get_rep_f64_generic<'a>(&self, m: &'a Message) -> &'a [f64]; + + fn get_reflect<'a>(&self, m: &'a Message) -> ReflectFieldRef<'a>; +} + + +trait GetSingularMessage { + fn get_message<'a>(&self, m: &'a M) -> &'a Message; +} + +struct GetSingularMessageImpl { + get: for<'a> fn(&'a M) -> &'a N, +} + +impl GetSingularMessage for GetSingularMessageImpl { + fn get_message<'a>(&self, m: &'a M) -> &'a Message { + (self.get)(m) + } +} + + +trait GetSingularEnum { + fn get_enum(&self, m: &M) -> &'static EnumValueDescriptor; +} + +struct GetSingularEnumImpl { + get: fn(&M) -> E, +} + +impl GetSingularEnum for GetSingularEnumImpl { + fn get_enum(&self, m: &M) -> &'static EnumValueDescriptor { + (self.get)(m).descriptor() + } +} + + +trait GetRepeatedMessage { + fn len_field(&self, m: &M) -> usize; + fn get_message_item<'a>(&self, m: &'a M, index: usize) -> &'a Message; + fn reflect_repeated_message<'a>(&self, m: &'a M) -> Box + 'a>; +} + +struct GetRepeatedMessageImpl { + get: for<'a> fn(&'a M) -> &'a [N], +} + +impl GetRepeatedMessage for GetRepeatedMessageImpl { + fn len_field(&self, m: &M) -> usize { + (self.get)(m).len() + } + + fn get_message_item<'a>(&self, m: &'a M, index: usize) -> &'a Message { + &(self.get)(m)[index] + } + + fn reflect_repeated_message<'a>(&self, m: &'a M) -> Box + 'a> { + Box::new(ReflectRepeatedMessageImpl { slice: (self.get)(m) }) + } +} + + +trait GetRepeatedEnum { + fn len_field(&self, m: &M) -> usize; + fn get_enum_item(&self, m: &M, index: usize) -> &'static EnumValueDescriptor; + fn reflect_repeated_enum<'a>(&self, m: &'a M) -> Box + 'a>; +} + +struct GetRepeatedEnumImpl { + get: for<'a> fn(&'a M) -> &'a [E], +} + +impl GetRepeatedEnum for GetRepeatedEnumImpl { + fn len_field(&self, m: &M) -> usize { + (self.get)(m).len() + } + + fn get_enum_item(&self, m: &M, index: usize) -> &'static EnumValueDescriptor { + (self.get)(m)[index].descriptor() + } + + fn reflect_repeated_enum<'a>(&self, m: &'a M) -> Box + 'a> { + Box::new(ReflectRepeatedEnumImpl { slice: (self.get)(m) }) + } +} + + + + +trait GetSetCopyFns { + fn get_field<'a>(&self, m: &'a M) -> ProtobufValueRef<'a>; +} + +struct GetSetCopyFnsImpl { + get: fn(&M) -> V, + _set: fn(&mut M, V), +} + +impl GetSetCopyFns for GetSetCopyFnsImpl { + fn get_field<'a>(&self, m: &'a M) -> ProtobufValueRef<'a> { + (&(self.get)(m) as &ProtobufValue).as_ref_copy() + } +} + + +enum SingularGetSet { + Copy(Box>), + String(for<'a> fn(&'a M) -> &'a str, fn(&mut M, String)), + Bytes(for<'a> fn(&'a M) -> &'a [u8], fn(&mut M, Vec)), + Enum(Box + 'static>), + Message(Box + 'static>), +} + +impl SingularGetSet { + fn get_ref<'a>(&self, m: &'a M) -> ProtobufValueRef<'a> { + match self { + &SingularGetSet::Copy(ref copy) => copy.get_field(m), + &SingularGetSet::String(get, _) => ProtobufValueRef::String(get(m)), + &SingularGetSet::Bytes(get, _) => ProtobufValueRef::Bytes(get(m)), + &SingularGetSet::Enum(ref get) => ProtobufValueRef::Enum(get.get_enum(m)), + &SingularGetSet::Message(ref get) => ProtobufValueRef::Message(get.get_message(m)), + } + } +} + +// for rust-protobuf up to 1.0.24 +enum RepeatedOldGet { + U32(for<'a> fn(&'a M) -> &'a [u32]), + U64(for<'a> fn(&'a M) -> &'a [u64]), + I32(for<'a> fn(&'a M) -> &'a [i32]), + I64(for<'a> fn(&'a M) -> &'a [i64]), + F32(for<'a> fn(&'a M) -> &'a [f32]), + F64(for<'a> fn(&'a M) -> &'a [f64]), + Bool(for<'a> fn(&'a M) -> &'a [bool]), + String(for<'a> fn(&'a M) -> &'a [String]), + Bytes(for<'a> fn(&'a M) -> &'a [Vec]), + Enum(Box + 'static>), + Message(Box + 'static>), +} + +impl RepeatedOldGet { + fn len_field(&self, m: &M) -> usize { + match *self { + RepeatedOldGet::U32(get) => get(m).len(), + RepeatedOldGet::U64(get) => get(m).len(), + RepeatedOldGet::I32(get) => get(m).len(), + RepeatedOldGet::I64(get) => get(m).len(), + RepeatedOldGet::F32(get) => get(m).len(), + RepeatedOldGet::F64(get) => get(m).len(), + RepeatedOldGet::Bool(get) => get(m).len(), + RepeatedOldGet::String(get) => get(m).len(), + RepeatedOldGet::Bytes(get) => get(m).len(), + RepeatedOldGet::Enum(ref get) => get.len_field(m), + RepeatedOldGet::Message(ref get) => get.len_field(m), + } + } + + fn get_repeated<'a>(&self, m: &'a M) -> ReflectRepeatedRef<'a> { + match *self { + RepeatedOldGet::U32(get) => ReflectRepeatedRef::U32(get(m)), + RepeatedOldGet::U64(get) => ReflectRepeatedRef::U64(get(m)), + RepeatedOldGet::I32(get) => ReflectRepeatedRef::I32(get(m)), + RepeatedOldGet::I64(get) => ReflectRepeatedRef::I64(get(m)), + RepeatedOldGet::F32(get) => ReflectRepeatedRef::F32(get(m)), + RepeatedOldGet::F64(get) => ReflectRepeatedRef::F64(get(m)), + RepeatedOldGet::Bool(get) => ReflectRepeatedRef::Bool(get(m)), + RepeatedOldGet::String(get) => ReflectRepeatedRef::String(get(m)), + RepeatedOldGet::Bytes(get) => ReflectRepeatedRef::Bytes(get(m)), + RepeatedOldGet::Enum(ref get) => ReflectRepeatedRef::Enum(get.reflect_repeated_enum(m)), + RepeatedOldGet::Message(ref get) => ReflectRepeatedRef::Message( + get.reflect_repeated_message(m), + ), + } + } +} + +trait FieldAccessor2 +where + M : Message + 'static, +{ + fn get_field<'a>(&self, &'a M) -> &'a R; + fn mut_field<'a>(&self, &'a mut M) -> &'a mut R; +} + +struct MessageGetMut +where + M : Message + 'static, +{ + get_field: for<'a> fn(&'a M) -> &'a L, + mut_field: for<'a> fn(&'a mut M) -> &'a mut L, +} + + +enum FieldAccessorFunctions { + // up to 1.0.24 optional or required + SingularHasGetSet { + has: fn(&M) -> bool, + get_set: SingularGetSet, + }, + // up to 1.0.24 repeated + RepeatedOld(RepeatedOldGet), + // protobuf 3 simple field + Simple(Box>), + // optional, required or message + Optional(Box>), + // repeated + Repeated(Box>), + // protobuf 3 map + Map(Box>), +} + + +struct FieldAccessorImpl { + name: &'static str, + fns: FieldAccessorFunctions, +} + +impl FieldAccessorImpl { + fn get_value_option<'a>(&self, m: &'a M) -> Option> { + match self.fns { + FieldAccessorFunctions::Repeated(..) | + FieldAccessorFunctions::RepeatedOld(..) | + FieldAccessorFunctions::Map(..) => panic!("repeated"), + FieldAccessorFunctions::Simple(ref a) => Some(a.get_field(m).as_ref()), + FieldAccessorFunctions::Optional(ref a) => { + a.get_field(m).to_option().map(|v| v.as_ref()) + } + FieldAccessorFunctions::SingularHasGetSet { + ref has, + ref get_set, + } => { + if !has(m) { + None + } else { + Some(get_set.get_ref(m)) + } + } + } + } +} + +impl FieldAccessor for FieldAccessorImpl { + fn name_generic(&self) -> &'static str { + self.name + } + + fn has_field_generic(&self, m: &Message) -> bool { + match self.fns { + FieldAccessorFunctions::SingularHasGetSet { has, .. } => has(message_down_cast(m)), + FieldAccessorFunctions::Optional(ref a) => { + a.get_field(message_down_cast(m)).to_option().is_some() + } + FieldAccessorFunctions::Simple(ref a) => { + a.get_field(message_down_cast(m)).is_non_zero() + } + _ => panic!(), + } + } + + fn len_field_generic(&self, m: &Message) -> usize { + match self.fns { + FieldAccessorFunctions::RepeatedOld(ref r) => r.len_field(message_down_cast(m)), + FieldAccessorFunctions::Repeated(ref a) => a.get_field(message_down_cast(m)).len(), + FieldAccessorFunctions::Map(ref a) => a.get_field(message_down_cast(m)).len(), + _ => panic!("not repeated"), + } + } + + fn get_message_generic<'a>(&self, m: &'a Message) -> &'a Message { + match self.fns { + FieldAccessorFunctions::SingularHasGetSet { + get_set: SingularGetSet::Message(ref get), .. + } => get.get_message(message_down_cast(m)), + _ => panic!(), + } + } + + fn get_enum_generic(&self, m: &Message) -> &'static EnumValueDescriptor { + match self.fns { + FieldAccessorFunctions::SingularHasGetSet { + get_set: SingularGetSet::Enum(ref get), .. + } => get.get_enum(message_down_cast(m)), + _ => panic!(), + } + } + + fn get_str_generic<'a>(&self, m: &'a Message) -> &'a str { + match self.get_value_option(message_down_cast(m)) { + Some(ProtobufValueRef::String(v)) => v, + Some(_) => panic!("wrong type"), + None => "", // TODO: check type + } + } + + fn get_bytes_generic<'a>(&self, m: &'a Message) -> &'a [u8] { + match self.get_value_option(message_down_cast(m)) { + Some(ProtobufValueRef::Bytes(v)) => v, + Some(_) => panic!("wrong type"), + None => b"", // TODO: check type + } + } + + fn get_u32_generic(&self, m: &Message) -> u32 { + match self.get_value_option(message_down_cast(m)) { + Some(ProtobufValueRef::U32(v)) => v, + Some(_) => panic!("wrong type"), + None => 0, // TODO: check type + } + } + + fn get_u64_generic(&self, m: &Message) -> u64 { + match self.get_value_option(message_down_cast(m)) { + Some(ProtobufValueRef::U64(v)) => v, + Some(_) => panic!("wrong type"), + None => 0, // TODO: check type + } + } + + fn get_i32_generic(&self, m: &Message) -> i32 { + match self.get_value_option(message_down_cast(m)) { + Some(ProtobufValueRef::I32(v)) => v, + Some(_) => panic!("wrong type"), + None => 0, // TODO: check type + } + } + + fn get_i64_generic(&self, m: &Message) -> i64 { + match self.get_value_option(message_down_cast(m)) { + Some(ProtobufValueRef::I64(v)) => v, + Some(_) => panic!("wrong type"), + None => 0, // TODO: check type + } + } + + fn get_f32_generic(&self, m: &Message) -> f32 { + match self.get_value_option(message_down_cast(m)) { + Some(ProtobufValueRef::F32(v)) => v, + Some(_) => panic!("wrong type"), + None => 0.0, // TODO: check type + } + } + + fn get_f64_generic(&self, m: &Message) -> f64 { + match self.get_value_option(message_down_cast(m)) { + Some(ProtobufValueRef::F64(v)) => v, + Some(_) => panic!("wrong type"), + None => 0.0, // TODO: check type + } + } + + fn get_bool_generic(&self, m: &Message) -> bool { + match self.get_value_option(message_down_cast(m)) { + Some(ProtobufValueRef::Bool(v)) => v, + Some(_) => panic!("wrong type"), + None => false, // TODO: check type + } + } + + fn get_rep_message_item_generic<'a>(&self, m: &'a Message, index: usize) -> &'a Message { + match self.fns { + FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::Message(ref get)) => { + get.get_message_item(message_down_cast(m), index) + } + _ => panic!(), + } + } + + fn get_rep_enum_item_generic(&self, m: &Message, index: usize) -> &'static EnumValueDescriptor { + match self.fns { + FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::Enum(ref get)) => { + get.get_enum_item(message_down_cast(m), index) + } + _ => panic!(), + } + } + + fn get_rep_str_generic<'a>(&self, m: &'a Message) -> &'a [String] { + match self.fns { + FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::String(get)) => get( + message_down_cast(m), + ), + _ => panic!(), + } + } + + fn get_rep_bytes_generic<'a>(&self, m: &'a Message) -> &'a [Vec] { + match self.fns { + FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::Bytes(get)) => get( + message_down_cast(m), + ), + _ => panic!(), + } + } + + fn get_rep_u32_generic<'a>(&self, m: &'a Message) -> &'a [u32] { + match self.fns { + FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::U32(get)) => get( + message_down_cast(m), + ), + _ => panic!(), + } + } + + fn get_rep_u64_generic<'a>(&self, m: &'a Message) -> &'a [u64] { + match self.fns { + FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::U64(get)) => get( + message_down_cast(m), + ), + _ => panic!(), + } + } + + fn get_rep_i32_generic<'a>(&self, m: &'a Message) -> &'a [i32] { + match self.fns { + FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::I32(get)) => get( + message_down_cast(m), + ), + _ => panic!(), + } + } + + fn get_rep_i64_generic<'a>(&self, m: &'a Message) -> &'a [i64] { + match self.fns { + FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::I64(get)) => get( + message_down_cast(m), + ), + _ => panic!(), + } + } + + fn get_rep_f32_generic<'a>(&self, m: &'a Message) -> &'a [f32] { + match self.fns { + FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::F32(get)) => get( + message_down_cast(m), + ), + _ => panic!(), + } + } + + fn get_rep_f64_generic<'a>(&self, m: &'a Message) -> &'a [f64] { + match self.fns { + FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::F64(get)) => get( + message_down_cast(m), + ), + _ => panic!(), + } + } + + fn get_rep_bool_generic<'a>(&self, m: &'a Message) -> &'a [bool] { + match self.fns { + FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::Bool(get)) => get( + message_down_cast(m), + ), + _ => panic!(), + } + } + + fn get_reflect<'a>(&self, m: &'a Message) -> ReflectFieldRef<'a> { + match self.fns { + FieldAccessorFunctions::Repeated(ref accessor2) => { + ReflectFieldRef::Repeated(accessor2.get_field(message_down_cast(m))) + } + FieldAccessorFunctions::Map(ref accessor2) => { + ReflectFieldRef::Map(accessor2.get_field(message_down_cast(m))) + } + FieldAccessorFunctions::Optional(ref accessor2) => { + ReflectFieldRef::Optional( + accessor2 + .get_field(message_down_cast(m)) + .to_option() + .map(|v| v.as_ref()), + ) + } + FieldAccessorFunctions::Simple(ref accessor2) => { + ReflectFieldRef::Optional({ + let v = accessor2.get_field(message_down_cast(m)); + if v.is_non_zero() { + Some(v.as_ref()) + } else { + None + } + }) + } + FieldAccessorFunctions::SingularHasGetSet { + ref has, + ref get_set, + } => { + ReflectFieldRef::Optional(if has(message_down_cast(m)) { + Some(get_set.get_ref(message_down_cast(m))) + } else { + None + }) + } + FieldAccessorFunctions::RepeatedOld(ref get) => { + ReflectFieldRef::RepeatedOld(get.get_repeated(message_down_cast(m))) + } + } + } +} + + +// singular + +fn set_panic(_: &mut A, _: B) { + panic!() +} + +pub fn make_singular_u32_accessor( + name: &'static str, + has: fn(&M) -> bool, + get: fn(&M) -> u32, +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::SingularHasGetSet { + has: has, + get_set: SingularGetSet::Copy(Box::new(GetSetCopyFnsImpl { + get: get, + _set: set_panic, + })), + }, + }) +} + +pub fn make_singular_i32_accessor( + name: &'static str, + has: fn(&M) -> bool, + get: fn(&M) -> i32, +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::SingularHasGetSet { + has: has, + get_set: SingularGetSet::Copy(Box::new(GetSetCopyFnsImpl { + get: get, + _set: set_panic, + })), + }, + }) +} + +pub fn make_singular_u64_accessor( + name: &'static str, + has: fn(&M) -> bool, + get: fn(&M) -> u64, +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::SingularHasGetSet { + has: has, + get_set: SingularGetSet::Copy(Box::new(GetSetCopyFnsImpl { + get: get, + _set: set_panic, + })), + }, + }) +} + +pub fn make_singular_i64_accessor( + name: &'static str, + has: fn(&M) -> bool, + get: fn(&M) -> i64, +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::SingularHasGetSet { + has: has, + get_set: SingularGetSet::Copy(Box::new(GetSetCopyFnsImpl { + get: get, + _set: set_panic, + })), + }, + }) +} + +pub fn make_singular_f32_accessor( + name: &'static str, + has: fn(&M) -> bool, + get: fn(&M) -> f32, +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::SingularHasGetSet { + has: has, + get_set: SingularGetSet::Copy(Box::new(GetSetCopyFnsImpl { + get: get, + _set: set_panic, + })), + }, + }) +} + +pub fn make_singular_f64_accessor( + name: &'static str, + has: fn(&M) -> bool, + get: fn(&M) -> f64, +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::SingularHasGetSet { + has: has, + get_set: SingularGetSet::Copy(Box::new(GetSetCopyFnsImpl { + get: get, + _set: set_panic, + })), + }, + }) +} + +pub fn make_singular_bool_accessor( + name: &'static str, + has: fn(&M) -> bool, + get: fn(&M) -> bool, +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::SingularHasGetSet { + has: has, + get_set: SingularGetSet::Copy(Box::new(GetSetCopyFnsImpl { + get: get, + _set: set_panic, + })), + }, + }) +} + +pub fn make_singular_enum_accessor( + name: &'static str, + has: fn(&M) -> bool, + get: fn(&M) -> E, +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::SingularHasGetSet { + has: has, + get_set: SingularGetSet::Enum(Box::new(GetSingularEnumImpl { get: get })), + }, + }) +} + +pub fn make_singular_string_accessor( + name: &'static str, + has: fn(&M) -> bool, + get: for<'a> fn(&'a M) -> &'a str, +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::SingularHasGetSet { + has: has, + get_set: SingularGetSet::String(get, set_panic), + }, + }) +} + +pub fn make_singular_bytes_accessor( + name: &'static str, + has: fn(&M) -> bool, + get: for<'a> fn(&'a M) -> &'a [u8], +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::SingularHasGetSet { + has: has, + get_set: SingularGetSet::Bytes(get, set_panic), + }, + }) +} + +pub fn make_singular_message_accessor( + name: &'static str, + has: fn(&M) -> bool, + get: for<'a> fn(&'a M) -> &'a F, +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::SingularHasGetSet { + has: has, + get_set: SingularGetSet::Message(Box::new(GetSingularMessageImpl { get: get })), + }, + }) +} + +// repeated + +#[deprecated] +pub fn make_repeated_u32_accessor( + name: &'static str, + get: for<'a> fn(&'a M) -> &'a [u32], +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::U32(get)), + }) +} + +#[deprecated] +pub fn make_repeated_i32_accessor( + name: &'static str, + get: for<'a> fn(&'a M) -> &'a [i32], +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::I32(get)), + }) +} + +#[deprecated] +pub fn make_repeated_u64_accessor( + name: &'static str, + get: for<'a> fn(&'a M) -> &'a [u64], +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::U64(get)), + }) +} + +#[deprecated] +pub fn make_repeated_i64_accessor( + name: &'static str, + get: for<'a> fn(&'a M) -> &'a [i64], +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::I64(get)), + }) +} + +#[deprecated] +pub fn make_repeated_f32_accessor( + name: &'static str, + get: for<'a> fn(&'a M) -> &'a [f32], +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::F32(get)), + }) +} + +#[deprecated] +pub fn make_repeated_f64_accessor( + name: &'static str, + get: for<'a> fn(&'a M) -> &'a [f64], +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::F64(get)), + }) +} + +#[deprecated] +pub fn make_repeated_bool_accessor( + name: &'static str, + get: for<'a> fn(&'a M) -> &'a [bool], +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::Bool(get)), + }) +} + +#[deprecated] +pub fn make_repeated_string_accessor( + name: &'static str, + get: for<'a> fn(&'a M) -> &'a [String], +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::String(get)), + }) +} + +#[deprecated] +pub fn make_repeated_bytes_accessor( + name: &'static str, + get: for<'a> fn(&'a M) -> &'a [Vec], +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::Bytes(get)), + }) +} + +#[deprecated] +pub fn make_repeated_enum_accessor( + name: &'static str, + get: for<'a> fn(&'a M) -> &'a [E], +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::Enum( + Box::new(GetRepeatedEnumImpl { get: get }), + )), + }) +} + +#[deprecated] +pub fn make_repeated_message_accessor( + name: &'static str, + get: for<'a> fn(&'a M) -> &'a [F], +) -> Box { + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::RepeatedOld(RepeatedOldGet::Message( + Box::new(GetRepeatedMessageImpl { get: get }), + )), + }) +} + + + +impl FieldAccessor2 for MessageGetMut> +where + M : Message + 'static, + V : ProtobufValue + 'static, +{ + fn get_field<'a>(&self, m: &'a M) -> &'a ReflectRepeated { + (self.get_field)(m) as &ReflectRepeated + } + + fn mut_field<'a>(&self, m: &'a mut M) -> &'a mut ReflectRepeated { + (self.mut_field)(m) as &mut ReflectRepeated + } +} + + + +pub fn make_vec_accessor( + name: &'static str, + get_vec: for<'a> fn(&'a M) -> &'a Vec, + mut_vec: for<'a> fn(&'a mut M) -> &'a mut Vec, +) -> Box +where + M : Message + 'static, + V : ProtobufType + 'static, +{ + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::Repeated(Box::new(MessageGetMut::> { + get_field: get_vec, + mut_field: mut_vec, + })), + }) +} + + +impl FieldAccessor2 for MessageGetMut> +where + M : Message + 'static, + V : ProtobufValue + 'static, +{ + fn get_field<'a>(&self, m: &'a M) -> &'a ReflectRepeated { + (self.get_field)(m) as &ReflectRepeated + } + + fn mut_field<'a>(&self, m: &'a mut M) -> &'a mut ReflectRepeated { + (self.mut_field)(m) as &mut ReflectRepeated + } +} + + +pub fn make_repeated_field_accessor( + name: &'static str, + get_vec: for<'a> fn(&'a M) -> &'a RepeatedField, + mut_vec: for<'a> fn(&'a mut M) + -> &'a mut RepeatedField, +) -> Box +where + M : Message + 'static, + V : ProtobufType + 'static, +{ + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::Repeated( + Box::new(MessageGetMut::> { + get_field: get_vec, + mut_field: mut_vec, + }), + ), + }) +} + +impl FieldAccessor2 for MessageGetMut> +where + M : Message + 'static, + V : ProtobufValue + Clone + 'static, +{ + fn get_field<'a>(&self, m: &'a M) -> &'a ReflectOptional { + (self.get_field)(m) as &ReflectOptional + } + + fn mut_field<'a>(&self, m: &'a mut M) -> &'a mut ReflectOptional { + (self.mut_field)(m) as &mut ReflectOptional + } +} + +//#[deprecated] +pub fn make_option_accessor( + name: &'static str, + get_field: for<'a> fn(&'a M) -> &'a Option, + mut_field: for<'a> fn(&'a mut M) -> &'a mut Option, +) -> Box +where + M : Message + 'static, + V : ProtobufType + 'static, +{ + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::Optional(Box::new(MessageGetMut::> { + get_field: get_field, + mut_field: mut_field, + })), + }) +} + + +pub fn make_has_get_set_clear_accessor( + _name: &'static str, + _has_value: for<'a> fn(&'a M) -> bool, + _get_value: for<'a> fn(&'a M) -> &'a V::Value, + _set_value: for<'a> fn(&'a M, V::Value), + _clr_value: for<'a> fn(&'a M), +) -> Box +where + M : Message + 'static, + V : ProtobufType + 'static, +{ + unimplemented!() +} + + +pub fn make_has_get_mut_clear_accessor( + _name: &'static str, + _has_value: for<'a> fn(&'a M) -> bool, + _get_value: for<'a> fn(&'a M) -> &'a V::Value, + _mut_value: for<'a> fn(&'a M) -> &'a mut V::Value, + _clr_value: for<'a> fn(&'a M), +) -> Box +where + M : Message + 'static, + V : ProtobufType + 'static, +{ + unimplemented!() +} + + +impl FieldAccessor2 for MessageGetMut> +where + M : Message + 'static, + V : ProtobufValue + Clone + 'static, +{ + fn get_field<'a>(&self, m: &'a M) -> &'a ReflectOptional { + (self.get_field)(m) as &ReflectOptional + } + + fn mut_field<'a>(&self, m: &'a mut M) -> &'a mut ReflectOptional { + (self.mut_field)(m) as &mut ReflectOptional + } +} + +pub fn make_singular_field_accessor( + name: &'static str, + get_field: for<'a> fn(&'a M) -> &'a SingularField, + mut_field: for<'a> fn(&'a mut M) + -> &'a mut SingularField, +) -> Box +where + M : Message + 'static, + V : ProtobufType + 'static, +{ + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::Optional( + Box::new(MessageGetMut::> { + get_field: get_field, + mut_field: mut_field, + }), + ), + }) +} + +impl FieldAccessor2 for MessageGetMut> +where + M : Message + 'static, + V : ProtobufValue + Clone + 'static, +{ + fn get_field<'a>(&self, m: &'a M) -> &'a ReflectOptional { + (self.get_field)(m) as &ReflectOptional + } + + fn mut_field<'a>(&self, m: &'a mut M) -> &'a mut ReflectOptional { + (self.mut_field)(m) as &mut ReflectOptional + } +} + +pub fn make_singular_ptr_field_accessor( + name: &'static str, + get_field: for<'a> fn(&'a M) + -> &'a SingularPtrField, + mut_field: for<'a> fn(&'a mut M) + -> &'a mut SingularPtrField, +) -> Box +where + M : Message + 'static, + V : ProtobufType + 'static, +{ + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::Optional( + Box::new(MessageGetMut::> { + get_field: get_field, + mut_field: mut_field, + }), + ), + }) +} + +impl FieldAccessor2 for MessageGetMut +where + M : Message + 'static, + V : ProtobufValue + Clone + 'static, +{ + fn get_field<'a>(&self, m: &'a M) -> &'a ProtobufValue { + (self.get_field)(m) as &ProtobufValue + } + + fn mut_field<'a>(&self, m: &'a mut M) -> &'a mut ProtobufValue { + (self.mut_field)(m) as &mut ProtobufValue + } +} + +pub fn make_simple_field_accessor( + name: &'static str, + get_field: for<'a> fn(&'a M) -> &'a V::Value, + mut_field: for<'a> fn(&'a mut M) -> &'a mut V::Value, +) -> Box +where + M : Message + 'static, + V : ProtobufType + 'static, +{ + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::Simple(Box::new(MessageGetMut:: { + get_field: get_field, + mut_field: mut_field, + })), + }) +} + + +impl FieldAccessor2 for MessageGetMut> +where + M : Message + 'static, + K : ProtobufValue + 'static, + V : ProtobufValue + 'static, + K : Hash + Eq, +{ + fn get_field<'a>(&self, m: &'a M) -> &'a ReflectMap { + (self.get_field)(m) as &ReflectMap + } + + fn mut_field<'a>(&self, m: &'a mut M) -> &'a mut ReflectMap { + (self.mut_field)(m) as &mut ReflectMap + } +} + + +pub fn make_map_accessor( + name: &'static str, + get_field: for<'a> fn(&'a M) + -> &'a HashMap, + mut_field: for<'a> fn(&'a mut M) + -> &'a mut HashMap, +) -> Box +where + M : Message + 'static, + K : ProtobufType + 'static, + V : ProtobufType + 'static, + ::Value : Hash + Eq, +{ + Box::new(FieldAccessorImpl { + name: name, + fns: FieldAccessorFunctions::Map( + Box::new(MessageGetMut::> { + get_field: get_field, + mut_field: mut_field, + }), + ), + }) +} diff --git a/third_party/protobuf/src/reflect/map.rs b/third_party/protobuf/src/reflect/map.rs new file mode 100644 index 000000000..7c35db02b --- /dev/null +++ b/third_party/protobuf/src/reflect/map.rs @@ -0,0 +1,68 @@ +use std::hash::Hash; +use std::collections::HashMap; +use std::collections::hash_map; +use std::boxed::Box; + +use super::value::ProtobufValue; + + +/// Implemented for `HashMap` with appropriate keys and values +pub trait ReflectMap: 'static { + fn reflect_iter(&self) -> ReflectMapIter; + + fn len(&self) -> usize; +} + +impl ReflectMap + for HashMap { + fn reflect_iter<'a>(&'a self) -> ReflectMapIter<'a> { + ReflectMapIter { imp: Box::new(ReflectMapIterImpl::<'a, K, V> { iter: self.iter() }) } + } + + fn len(&self) -> usize { + HashMap::len(self) + } +} + + +trait ReflectMapIterTrait<'a> { + fn next(&mut self) -> Option<(&'a ProtobufValue, &'a ProtobufValue)>; +} + +struct ReflectMapIterImpl<'a, K : Eq + Hash + 'static, V : 'static> { + iter: hash_map::Iter<'a, K, V>, +} + +impl< + 'a, + K : ProtobufValue + Eq + Hash + 'static, + V : ProtobufValue + 'static, +> ReflectMapIterTrait<'a> for ReflectMapIterImpl<'a, K, V> { + fn next(&mut self) -> Option<(&'a ProtobufValue, &'a ProtobufValue)> { + match self.iter.next() { + Some((k, v)) => Some((k as &ProtobufValue, v as &ProtobufValue)), + None => None, + } + } +} + +pub struct ReflectMapIter<'a> { + imp: Box + 'a>, +} + +impl<'a> Iterator for ReflectMapIter<'a> { + type Item = (&'a ProtobufValue, &'a ProtobufValue); + + fn next(&mut self) -> Option<(&'a ProtobufValue, &'a ProtobufValue)> { + self.imp.next() + } +} + +impl<'a> IntoIterator for &'a ReflectMap { + type IntoIter = ReflectMapIter<'a>; + type Item = (&'a ProtobufValue, &'a ProtobufValue); + + fn into_iter(self) -> Self::IntoIter { + self.reflect_iter() + } +} diff --git a/third_party/protobuf/src/reflect/mod.rs b/third_party/protobuf/src/reflect/mod.rs new file mode 100644 index 000000000..0e9e04ac6 --- /dev/null +++ b/third_party/protobuf/src/reflect/mod.rs @@ -0,0 +1,404 @@ +use std::collections::HashMap; +use std::default::Default; +use std::marker; +use std::boxed::Box; +use std::string::String; +use std::string::ToString; +use std::vec::Vec; + +use protocore::Message; +use protocore::MessageStatic; +use protocore::ProtobufEnum; +use descriptor::FileDescriptorProto; +use descriptor::DescriptorProto; +use descriptor::FieldDescriptorProto; +use descriptor::EnumDescriptorProto; +use descriptor::EnumValueDescriptorProto; +use descriptor::FieldDescriptorProto_Label; +use descriptor::FieldDescriptorProto_Type; +use descriptorx::find_enum_by_rust_name; +use descriptorx::find_message_by_rust_name; +use reflect::accessor::FieldAccessor; + + +pub mod accessor; +mod map; +mod repeated; +mod value; +mod optional; + +use self::repeated::ReflectRepeated; +use self::repeated::ReflectRepeatedRef; +use self::map::ReflectMap; + +pub use self::value::ProtobufValue; +pub use self::value::ProtobufValueRef; + + +pub struct FieldDescriptor { + proto: &'static FieldDescriptorProto, + accessor: Box, +} + +impl FieldDescriptor { + fn new( + a: Box, + proto: &'static FieldDescriptorProto, + ) -> FieldDescriptor { + assert_eq!(proto.get_name(), a.name_generic()); + FieldDescriptor { + proto: proto, + accessor: a, + } + } + + pub fn proto(&self) -> &'static FieldDescriptorProto { + self.proto + } + + pub fn name(&self) -> &'static str { + self.proto.get_name() + } + + pub fn is_repeated(&self) -> bool { + self.proto.get_label() == FieldDescriptorProto_Label::LABEL_REPEATED + } + + pub fn has_field(&self, m: &Message) -> bool { + self.accessor.has_field_generic(m) + } + + pub fn len_field(&self, m: &Message) -> usize { + self.accessor.len_field_generic(m) + } + + pub fn get_message<'a>(&self, m: &'a Message) -> &'a Message { + self.accessor.get_message_generic(m) + } + + pub fn get_rep_message_item<'a>(&self, m: &'a Message, index: usize) -> &'a Message { + self.accessor.get_rep_message_item_generic(m, index) + } + + pub fn get_enum(&self, m: &Message) -> &'static EnumValueDescriptor { + self.accessor.get_enum_generic(m) + } + + pub fn get_rep_enum_item(&self, m: &Message, index: usize) -> &'static EnumValueDescriptor { + self.accessor.get_rep_enum_item_generic(m, index) + } + + pub fn get_str<'a>(&self, m: &'a Message) -> &'a str { + self.accessor.get_str_generic(m) + } + + pub fn get_rep_str<'a>(&self, m: &'a Message) -> &'a [String] { + self.accessor.get_rep_str_generic(m) + } + + pub fn get_rep_str_item<'a>(&self, m: &'a Message, index: usize) -> &'a str { + &self.get_rep_str(m)[index] + } + + pub fn get_bytes<'a>(&self, m: &'a Message) -> &'a [u8] { + self.accessor.get_bytes_generic(m) + } + + pub fn get_rep_bytes<'a>(&self, m: &'a Message) -> &'a [Vec] { + self.accessor.get_rep_bytes_generic(m) + } + + pub fn get_rep_bytes_item<'a>(&self, m: &'a Message, index: usize) -> &'a [u8] { + &self.get_rep_bytes(m)[index] + } + + pub fn get_u32(&self, m: &Message) -> u32 { + self.accessor.get_u32_generic(m) + } + + pub fn get_rep_u32<'a>(&self, m: &'a Message) -> &'a [u32] { + self.accessor.get_rep_u32_generic(m) + } + + pub fn get_u64(&self, m: &Message) -> u64 { + self.accessor.get_u64_generic(m) + } + + pub fn get_rep_u64<'a>(&self, m: &'a Message) -> &'a [u64] { + self.accessor.get_rep_u64_generic(m) + } + + pub fn get_i32(&self, m: &Message) -> i32 { + self.accessor.get_i32_generic(m) + } + + pub fn get_rep_i32<'a>(&self, m: &'a Message) -> &'a [i32] { + self.accessor.get_rep_i32_generic(m) + } + + pub fn get_i64(&self, m: &Message) -> i64 { + self.accessor.get_i64_generic(m) + } + + pub fn get_rep_i64<'a>(&self, m: &'a Message) -> &'a [i64] { + self.accessor.get_rep_i64_generic(m) + } + + pub fn get_bool(&self, m: &Message) -> bool { + self.accessor.get_bool_generic(m) + } + + pub fn get_rep_bool<'a>(&self, m: &'a Message) -> &'a [bool] { + self.accessor.get_rep_bool_generic(m) + } + + pub fn get_f32(&self, m: &Message) -> f32 { + self.accessor.get_f32_generic(m) + } + + pub fn get_rep_f32<'a>(&self, m: &'a Message) -> &'a [f32] { + self.accessor.get_rep_f32_generic(m) + } + + pub fn get_f64(&self, m: &Message) -> f64 { + self.accessor.get_f64_generic(m) + } + + pub fn get_rep_f64<'a>(&self, m: &'a Message) -> &'a [f64] { + self.accessor.get_rep_f64_generic(m) + } + + pub fn get_reflect<'a>(&self, m: &'a Message) -> ReflectFieldRef<'a> { + self.accessor.get_reflect(m) + } + + pub fn get_rep_item<'a>(&self, m: &'a Message, index: usize) -> ProtobufValueRef<'a> { + match self.proto().get_field_type() { + FieldDescriptorProto_Type::TYPE_MESSAGE => ProtobufValueRef::Message( + self.get_rep_message_item(m, index), + ), + FieldDescriptorProto_Type::TYPE_ENUM => ProtobufValueRef::Enum( + self.get_rep_enum_item(m, index), + ), + FieldDescriptorProto_Type::TYPE_STRING => ProtobufValueRef::String( + self.get_rep_str_item(m, index), + ), + FieldDescriptorProto_Type::TYPE_BYTES => ProtobufValueRef::Bytes( + self.get_rep_bytes_item(m, index), + ), + FieldDescriptorProto_Type::TYPE_INT32 | + FieldDescriptorProto_Type::TYPE_SINT32 | + FieldDescriptorProto_Type::TYPE_SFIXED32 => ProtobufValueRef::I32( + self.get_rep_i32(m)[index], + ), + FieldDescriptorProto_Type::TYPE_INT64 | + FieldDescriptorProto_Type::TYPE_SINT64 | + FieldDescriptorProto_Type::TYPE_SFIXED64 => ProtobufValueRef::I64( + self.get_rep_i64(m)[index], + ), + FieldDescriptorProto_Type::TYPE_UINT32 | + FieldDescriptorProto_Type::TYPE_FIXED32 => ProtobufValueRef::U32( + self.get_rep_u32(m)[index], + ), + FieldDescriptorProto_Type::TYPE_UINT64 | + FieldDescriptorProto_Type::TYPE_FIXED64 => ProtobufValueRef::U64( + self.get_rep_u64(m)[index], + ), + FieldDescriptorProto_Type::TYPE_BOOL => ProtobufValueRef::Bool( + self.get_rep_bool(m)[index], + ), + FieldDescriptorProto_Type::TYPE_FLOAT => ProtobufValueRef::F32( + self.get_rep_f32(m)[index], + ), + FieldDescriptorProto_Type::TYPE_DOUBLE => ProtobufValueRef::F64( + self.get_rep_f64(m)[index], + ), + FieldDescriptorProto_Type::TYPE_GROUP => unimplemented!(), + } + } +} + + +trait MessageFactory { + fn new_instance(&self) -> Box; +} + +struct MessageFactoryTyped { + _dummy: (), + _phantom_data: marker::PhantomData, +} + +impl MessageFactoryTyped { + fn new() -> MessageFactoryTyped { + MessageFactoryTyped { + _dummy: (), + _phantom_data: marker::PhantomData, + } + } +} + +impl MessageFactory for MessageFactoryTyped { + fn new_instance(&self) -> Box { + let m: M = Default::default(); + Box::new(m) + } +} + +pub struct MessageDescriptor { + full_name: String, + proto: &'static DescriptorProto, + factory: Box, + fields: Vec, + + index_by_name: HashMap, + index_by_number: HashMap, +} + +impl MessageDescriptor { + pub fn for_type() -> &'static MessageDescriptor { + MessageStatic::descriptor_static(None::) + } + + pub fn new( + rust_name: &'static str, + fields: Vec>, + file: &'static FileDescriptorProto, + ) -> MessageDescriptor { + let proto = find_message_by_rust_name(file, rust_name); + + let mut field_proto_by_name = HashMap::new(); + for field_proto in proto.message.get_field() { + field_proto_by_name.insert(field_proto.get_name(), field_proto); + } + + let mut index_by_name = HashMap::new(); + let mut index_by_number = HashMap::new(); + for (i, f) in proto.message.get_field().iter().enumerate() { + index_by_number.insert(f.get_number() as u32, i); + index_by_name.insert(f.get_name().to_string(), i); + } + + let mut full_name = file.get_package().to_string(); + if full_name.len() > 0 { + full_name.push('.'); + } + full_name.push_str(proto.message.get_name()); + + MessageDescriptor { + full_name: full_name, + proto: proto.message, + factory: Box::new(MessageFactoryTyped::::new()), + fields: fields + .into_iter() + .map(|f| { + let proto = *field_proto_by_name.get(&f.name_generic()).unwrap(); + FieldDescriptor::new(f, proto) + }) + .collect(), + index_by_name: index_by_name, + index_by_number: index_by_number, + } + } + + pub fn new_instance(&self) -> Box { + self.factory.new_instance() + } + + pub fn name(&self) -> &'static str { + self.proto.get_name() + } + + pub fn full_name(&self) -> &str { + &self.full_name[..] + } + + pub fn fields<'a>(&'a self) -> &'a [FieldDescriptor] { + &self.fields + } + + pub fn field_by_name<'a>(&'a self, name: &str) -> &'a FieldDescriptor { + // TODO: clone is weird + let &index = self.index_by_name.get(&name.to_string()).unwrap(); + &self.fields[index] + } + + pub fn field_by_number<'a>(&'a self, number: u32) -> &'a FieldDescriptor { + let &index = self.index_by_number.get(&number).unwrap(); + &self.fields[index] + } +} + +#[derive(Clone)] +pub struct EnumValueDescriptor { + proto: &'static EnumValueDescriptorProto, +} + +impl Copy for EnumValueDescriptor {} + +impl EnumValueDescriptor { + pub fn name(&self) -> &'static str { + self.proto.get_name() + } + + pub fn value(&self) -> i32 { + self.proto.get_number() + } +} + +pub struct EnumDescriptor { + proto: &'static EnumDescriptorProto, + values: Vec, + + index_by_name: HashMap, + index_by_number: HashMap, +} + +impl EnumDescriptor { + pub fn name(&self) -> &'static str { + self.proto.get_name() + } + + pub fn for_type() -> &'static EnumDescriptor { + ProtobufEnum::enum_descriptor_static(None::) + } + + pub fn new(rust_name: &'static str, file: &'static FileDescriptorProto) -> EnumDescriptor { + let proto = find_enum_by_rust_name(file, rust_name); + let mut index_by_name = HashMap::new(); + let mut index_by_number = HashMap::new(); + for (i, v) in proto.en.get_value().iter().enumerate() { + index_by_number.insert(v.get_number(), i); + index_by_name.insert(v.get_name().to_string(), i); + } + EnumDescriptor { + proto: proto.en, + values: proto + .en + .get_value() + .iter() + .map(|v| EnumValueDescriptor { proto: v }) + .collect(), + index_by_name: index_by_name, + index_by_number: index_by_number, + } + } + + pub fn value_by_name<'a>(&'a self, name: &str) -> &'a EnumValueDescriptor { + // TODO: clone is weird + let &index = self.index_by_name.get(&name.to_string()).unwrap(); + &self.values[index] + } + + pub fn value_by_number<'a>(&'a self, number: i32) -> &'a EnumValueDescriptor { + let &index = self.index_by_number.get(&number).unwrap(); + &self.values[index] + } +} + + +pub enum ReflectFieldRef<'a> { + Repeated(&'a ReflectRepeated), + RepeatedOld(ReflectRepeatedRef<'a>), + Map(&'a ReflectMap), + Optional(Option>), +} diff --git a/third_party/protobuf/src/reflect/optional.rs b/third_party/protobuf/src/reflect/optional.rs new file mode 100644 index 000000000..aefa9c30a --- /dev/null +++ b/third_party/protobuf/src/reflect/optional.rs @@ -0,0 +1,50 @@ +use std::mem; + +use super::value::ProtobufValue; + +use singular::*; + +pub trait ReflectOptional: 'static { + fn to_option(&self) -> Option<&ProtobufValue>; + + fn set_value(&mut self, value: &ProtobufValue); +} + +impl ReflectOptional for Option { + fn to_option(&self) -> Option<&ProtobufValue> { + self.as_ref().map(|v| v as &ProtobufValue) + } + + fn set_value(&mut self, value: &ProtobufValue) { + match value.as_any().downcast_ref::() { + Some(v) => mem::replace(self, Some(v.clone())), + None => panic!(), + }; + } +} + +impl ReflectOptional for SingularField { + fn to_option(&self) -> Option<&ProtobufValue> { + self.as_ref().map(|v| v as &ProtobufValue) + } + + fn set_value(&mut self, value: &ProtobufValue) { + match value.as_any().downcast_ref::() { + Some(v) => mem::replace(self, SingularField::some(v.clone())), + None => panic!(), + }; + } +} + +impl ReflectOptional for SingularPtrField { + fn to_option(&self) -> Option<&ProtobufValue> { + self.as_ref().map(|v| v as &ProtobufValue) + } + + fn set_value(&mut self, value: &ProtobufValue) { + match value.as_any().downcast_ref::() { + Some(v) => mem::replace(self, SingularPtrField::some(v.clone())), + None => panic!(), + }; + } +} diff --git a/third_party/protobuf/src/reflect/repeated.rs b/third_party/protobuf/src/reflect/repeated.rs new file mode 100644 index 000000000..fbb3d6481 --- /dev/null +++ b/third_party/protobuf/src/reflect/repeated.rs @@ -0,0 +1,225 @@ +use std::slice; +use std::boxed::Box; +use std::string::String; +use std::vec::Vec; + +use protocore::ProtobufEnum; +use protocore::Message; + +use super::value::ProtobufValue; +use super::value::ProtobufValueRef; + +use repeated::RepeatedField; + +pub trait ReflectRepeated: 'static { + fn reflect_iter(&self) -> ReflectRepeatedIter; + fn len(&self) -> usize; + fn get(&self, index: usize) -> &ProtobufValue; +} + +impl ReflectRepeated for Vec { + fn reflect_iter<'a>(&'a self) -> ReflectRepeatedIter<'a> { + ReflectRepeatedIter { + imp: Box::new(ReflectRepeatedIterImplSlice::<'a, V> { iter: self.iter() }), + } + } + + fn len(&self) -> usize { + Vec::len(self) + } + + fn get(&self, index: usize) -> &ProtobufValue { + &self[index] + } +} + +// useless +impl ReflectRepeated for [V] { + fn reflect_iter<'a>(&'a self) -> ReflectRepeatedIter<'a> { + ReflectRepeatedIter { + imp: Box::new(ReflectRepeatedIterImplSlice::<'a, V> { iter: self.iter() }), + } + } + + fn len(&self) -> usize { + <[_]>::len(self) + } + + fn get(&self, index: usize) -> &ProtobufValue { + &self[index] + } +} + +impl ReflectRepeated for RepeatedField { + fn reflect_iter<'a>(&'a self) -> ReflectRepeatedIter<'a> { + ReflectRepeatedIter { + imp: Box::new(ReflectRepeatedIterImplSlice::<'a, V> { iter: self.iter() }), + } + } + + fn len(&self) -> usize { + RepeatedField::len(self) + } + + fn get(&self, index: usize) -> &ProtobufValue { + &self[index] + } +} + +trait ReflectRepeatedIterTrait<'a> { + fn next(&mut self) -> Option<&'a ProtobufValue>; +} + +struct ReflectRepeatedIterImplSlice<'a, V : ProtobufValue + 'static> { + iter: slice::Iter<'a, V>, +} + +impl<'a, V : ProtobufValue + 'static> ReflectRepeatedIterTrait<'a> + for ReflectRepeatedIterImplSlice<'a, V> { + fn next(&mut self) -> Option<&'a ProtobufValue> { + self.iter.next().map(|v| v as &ProtobufValue) + } +} + +pub struct ReflectRepeatedIter<'a> { + imp: Box + 'a>, +} + +impl<'a> Iterator for ReflectRepeatedIter<'a> { + type Item = &'a ProtobufValue; + + fn next(&mut self) -> Option { + self.imp.next() + } +} + +impl<'a> IntoIterator for &'a ReflectRepeated { + type IntoIter = ReflectRepeatedIter<'a>; + type Item = &'a ProtobufValue; + + fn into_iter(self) -> Self::IntoIter { + self.reflect_iter() + } +} + +pub trait ReflectRepeatedEnum<'a> { + fn len(&self) -> usize; + + fn get(&self, index: usize) -> ProtobufValueRef<'a>; +} + +pub struct ReflectRepeatedEnumImpl<'a, E : ProtobufEnum> { + pub slice: &'a [E], +} + +impl<'a, E : ProtobufEnum + 'static> ReflectRepeatedEnum<'a> for ReflectRepeatedEnumImpl<'a, E> { + fn len(&self) -> usize { + self.slice.len() + } + + fn get(&self, index: usize) -> ProtobufValueRef<'a> { + ProtobufValueRef::Enum(self.slice[index].descriptor()) + } +} + +pub trait ReflectRepeatedMessage<'a> { + fn len(&self) -> usize; + + fn get(&self, index: usize) -> ProtobufValueRef<'a>; +} + +pub struct ReflectRepeatedMessageImpl<'a, M : Message> { + pub slice: &'a [M], +} + +impl<'a, M : Message> ReflectRepeatedMessage<'a> for ReflectRepeatedMessageImpl<'a, M> { + fn len(&self) -> usize { + self.slice.len() + } + + fn get(&self, index: usize) -> ProtobufValueRef<'a> { + ProtobufValueRef::Message(&self.slice[index]) + } +} + +pub enum ReflectRepeatedRef<'a> { + Generic(&'a ReflectRepeated), + U32(&'a [u32]), + U64(&'a [u64]), + I32(&'a [i32]), + I64(&'a [i64]), + F32(&'a [f32]), + F64(&'a [f64]), + Bool(&'a [bool]), + String(&'a [String]), + Bytes(&'a [Vec]), + Enum(Box + 'a>), + Message(Box + 'a>), +} + +impl<'a> ReflectRepeatedRef<'a> { + fn len(&self) -> usize { + match *self { + ReflectRepeatedRef::Generic(ref r) => r.len(), + ReflectRepeatedRef::U32(ref r) => r.len(), + ReflectRepeatedRef::U64(ref r) => r.len(), + ReflectRepeatedRef::I32(ref r) => r.len(), + ReflectRepeatedRef::I64(ref r) => r.len(), + ReflectRepeatedRef::F32(ref r) => r.len(), + ReflectRepeatedRef::F64(ref r) => r.len(), + ReflectRepeatedRef::Bool(ref r) => r.len(), + ReflectRepeatedRef::String(ref r) => r.len(), + ReflectRepeatedRef::Bytes(ref r) => r.len(), + ReflectRepeatedRef::Enum(ref r) => r.len(), + ReflectRepeatedRef::Message(ref r) => r.len(), + } + } + + fn get(&self, index: usize) -> ProtobufValueRef<'a> { + match *self { + ReflectRepeatedRef::Generic(ref r) => r.get(index).as_ref(), + ReflectRepeatedRef::U32(ref r) => ProtobufValueRef::U32(r[index]), + ReflectRepeatedRef::U64(ref r) => ProtobufValueRef::U64(r[index]), + ReflectRepeatedRef::I32(ref r) => ProtobufValueRef::I32(r[index]), + ReflectRepeatedRef::I64(ref r) => ProtobufValueRef::I64(r[index]), + ReflectRepeatedRef::F32(ref r) => ProtobufValueRef::F32(r[index]), + ReflectRepeatedRef::F64(ref r) => ProtobufValueRef::F64(r[index]), + ReflectRepeatedRef::Bool(ref r) => ProtobufValueRef::Bool(r[index]), + ReflectRepeatedRef::String(ref r) => ProtobufValueRef::String(&r[index]), + ReflectRepeatedRef::Bytes(ref r) => ProtobufValueRef::Bytes(&r[index]), + ReflectRepeatedRef::Enum(ref r) => r.get(index), + ReflectRepeatedRef::Message(ref r) => r.get(index), + } + } +} + +pub struct ReflectRepeatedRefIter<'a> { + repeated: &'a ReflectRepeatedRef<'a>, + pos: usize, +} + +impl<'a> Iterator for ReflectRepeatedRefIter<'a> { + type Item = ProtobufValueRef<'a>; + + fn next(&mut self) -> Option { + if self.pos < self.repeated.len() { + let pos = self.pos; + self.pos += 1; + Some(self.repeated.get(pos)) + } else { + None + } + } +} + +impl<'a> IntoIterator for &'a ReflectRepeatedRef<'a> { + type IntoIter = ReflectRepeatedRefIter<'a>; + type Item = ProtobufValueRef<'a>; + + fn into_iter(self) -> Self::IntoIter { + ReflectRepeatedRefIter { + repeated: self, + pos: 0, + } + } +} diff --git a/third_party/protobuf/src/reflect/value.rs b/third_party/protobuf/src/reflect/value.rs new file mode 100644 index 000000000..22f6ab8e2 --- /dev/null +++ b/third_party/protobuf/src/reflect/value.rs @@ -0,0 +1,163 @@ +use std::any::Any; +use std::string::String; +use std::vec::Vec; + +#[cfg(feature = "bytes")] +use bytes::Bytes; +#[cfg(feature = "bytes")] +use chars::Chars; + +use protocore::*; +use super::*; + +pub trait ProtobufValue: Any + 'static { + fn as_ref(&self) -> ProtobufValueRef; + + fn as_any(&self) -> &Any { + unimplemented!() + } + + fn is_non_zero(&self) -> bool { + self.as_ref().is_non_zero() + } + + fn as_ref_copy(&self) -> ProtobufValueRef<'static> +//where Self : Copy // TODO + { + match self.as_ref() { + ProtobufValueRef::Bool(v) => ProtobufValueRef::Bool(v), + ProtobufValueRef::U32(v) => ProtobufValueRef::U32(v), + ProtobufValueRef::U64(v) => ProtobufValueRef::U64(v), + ProtobufValueRef::I32(v) => ProtobufValueRef::I32(v), + ProtobufValueRef::I64(v) => ProtobufValueRef::I64(v), + ProtobufValueRef::F32(v) => ProtobufValueRef::F32(v), + ProtobufValueRef::F64(v) => ProtobufValueRef::F64(v), + ProtobufValueRef::Enum(v) => ProtobufValueRef::Enum(v), + ProtobufValueRef::String(..) | + ProtobufValueRef::Bytes(..) | + ProtobufValueRef::Message(..) => unreachable!(), + } + } +} + +impl ProtobufValue for u32 { + fn as_ref(&self) -> ProtobufValueRef { + ProtobufValueRef::U32(*self) + } +} + +impl ProtobufValue for u64 { + fn as_ref(&self) -> ProtobufValueRef { + ProtobufValueRef::U64(*self) + } +} + +impl ProtobufValue for i32 { + fn as_ref(&self) -> ProtobufValueRef { + ProtobufValueRef::I32(*self) + } +} + +impl ProtobufValue for i64 { + fn as_ref(&self) -> ProtobufValueRef { + ProtobufValueRef::I64(*self) + } +} + +impl ProtobufValue for f32 { + fn as_ref(&self) -> ProtobufValueRef { + ProtobufValueRef::F32(*self) + } +} + +impl ProtobufValue for f64 { + fn as_ref(&self) -> ProtobufValueRef { + ProtobufValueRef::F64(*self) + } +} + +impl ProtobufValue for bool { + fn as_ref(&self) -> ProtobufValueRef { + ProtobufValueRef::Bool(*self) + } +} + +impl ProtobufValue for String { + fn as_ref(&self) -> ProtobufValueRef { + ProtobufValueRef::String(*&self) + } +} + +impl ProtobufValue for str { + fn as_ref(&self) -> ProtobufValueRef { + ProtobufValueRef::String(self) + } +} + +impl ProtobufValue for Vec { + fn as_ref(&self) -> ProtobufValueRef { + ProtobufValueRef::Bytes(*&self) + } +} + +#[cfg(feature = "bytes")] +impl ProtobufValue for Bytes { + fn as_ref(&self) -> ProtobufValueRef { + ProtobufValueRef::Bytes(&*self) + } +} + +#[cfg(feature = "bytes")] +impl ProtobufValue for Chars { + fn as_ref(&self) -> ProtobufValueRef { + ProtobufValueRef::String(&*self) + } +} + +// conflicting implementations, so generated code is used instead +/* +impl ProtobufValue for E { + fn as_ref(&self) -> ProtobufValueRef { + ProtobufValueRef::Enum(self.descriptor()) + } +} + +impl ProtobufValue for M { + fn as_ref(&self) -> ProtobufValueRef { + ProtobufValueRef::Message(self) + } +} +*/ + + +pub enum ProtobufValueRef<'a> { + U32(u32), + U64(u64), + I32(i32), + I64(i64), + F32(f32), + F64(f64), + Bool(bool), + String(&'a str), + Bytes(&'a [u8]), + Enum(&'static EnumValueDescriptor), + Message(&'a Message), +} + +impl<'a> ProtobufValueRef<'a> { + pub fn is_non_zero(&self) -> bool { + match *self { + ProtobufValueRef::U32(v) => v != 0, + ProtobufValueRef::U64(v) => v != 0, + ProtobufValueRef::I32(v) => v != 0, + ProtobufValueRef::I64(v) => v != 0, + ProtobufValueRef::F32(v) => v != 0., + ProtobufValueRef::F64(v) => v != 0., + ProtobufValueRef::Bool(v) => v, + ProtobufValueRef::String(v) => !v.is_empty(), + ProtobufValueRef::Bytes(v) => !v.is_empty(), + ProtobufValueRef::Enum(v) => v.value() != 0, + ProtobufValueRef::Message(_) => true, + } + } +} diff --git a/third_party/protobuf/src/repeated.rs b/third_party/protobuf/src/repeated.rs new file mode 100644 index 000000000..6a5972fcb --- /dev/null +++ b/third_party/protobuf/src/repeated.rs @@ -0,0 +1,368 @@ +use std::vec; +use std::vec::Vec; +use std::slice; +use std::borrow::Borrow; +use std::default::Default; +use std::hash::Hash; +use std::hash::Hasher; +use std::iter::FromIterator; +use std::iter::IntoIterator; +use std::ops::Index; +use std::ops::IndexMut; +use std::ops::Deref; +use std::ops::DerefMut; +use std::cmp::Ordering; +use std::fmt; + +use clear::Clear; + +pub struct RepeatedField { + vec: Vec, + len: usize, +} + +impl RepeatedField { + #[inline] + pub fn len(&self) -> usize { + self.len + } + + #[inline] + pub fn clear(&mut self) { + self.len = 0; + } +} + +impl Clear for RepeatedField { + #[inline] + fn clear(&mut self) { + self.len = 0; + } +} + +impl Default for RepeatedField { + #[inline] + fn default() -> RepeatedField { + RepeatedField { + vec: Vec::new(), + len: 0, + } + } +} + +impl RepeatedField { + #[inline] + pub fn new() -> RepeatedField { + Default::default() + } + + #[inline] + pub fn from_vec(vec: Vec) -> RepeatedField { + let len = vec.len(); + RepeatedField { vec: vec, len: len } + } + + #[inline] + pub fn into_vec(self) -> Vec { + let mut vec = self.vec; + vec.truncate(self.len); + vec + } + + #[inline] + pub fn capacity(&self) -> usize { + self.vec.capacity() + } + + #[inline] + pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] { + &mut self.vec[..self.len] + } + + #[inline] + pub fn slice<'a>(&'a self, start: usize, end: usize) -> &'a [T] { + &self.as_ref()[start..end] + } + + #[inline] + pub fn slice_mut<'a>(&'a mut self, start: usize, end: usize) -> &'a mut [T] { + &mut self.as_mut_slice()[start..end] + } + + #[inline] + pub fn slice_from<'a>(&'a self, start: usize) -> &'a [T] { + &self.as_ref()[start..] + } + + #[inline] + pub fn slice_from_mut<'a>(&'a mut self, start: usize) -> &'a mut [T] { + &mut self.as_mut_slice()[start..] + } + + #[inline] + pub fn slice_to<'a>(&'a self, end: usize) -> &'a [T] { + &self.as_ref()[..end] + } + + #[inline] + pub fn slice_to_mut<'a>(&'a mut self, end: usize) -> &'a mut [T] { + &mut self.as_mut_slice()[..end] + } + + #[inline] + pub fn split_at<'a>(&'a self, mid: usize) -> (&'a [T], &'a [T]) { + self.as_ref().split_at(mid) + } + + #[inline] + pub fn split_at_mut<'a>(&'a mut self, mid: usize) -> (&'a mut [T], &'a mut [T]) { + self.as_mut_slice().split_at_mut(mid) + } + + #[inline] + pub fn tail<'a>(&'a self) -> &'a [T] { + &self.as_ref()[1..] + } + + #[inline] + pub fn last<'a>(&'a self) -> Option<&'a T> { + self.as_ref().last() + } + + #[inline] + pub fn last_mut<'a>(&'a mut self) -> Option<&'a mut T> { + self.as_mut_slice().last_mut() + } + + #[inline] + pub fn init<'a>(&'a self) -> &'a [T] { + let s = self.as_ref(); + &s[0..s.len() - 1] + } + + #[inline] + pub fn push(&mut self, value: T) { + if self.len == self.vec.len() { + self.vec.push(value); + } else { + self.vec[self.len] = value; + } + self.len += 1; + } + + #[inline] + pub fn pop(&mut self) -> Option { + if self.len == 0 { + None + } else { + self.vec.truncate(self.len); + self.len -= 1; + self.vec.pop() + } + } + + #[inline] + pub fn insert(&mut self, index: usize, value: T) { + assert!(index <= self.len); + self.vec.insert(index, value); + self.len += 1; + } + + #[inline] + pub fn remove(&mut self, index: usize) -> T { + assert!(index < self.len); + self.len -= 1; + self.vec.remove(index) + } + + #[inline] + pub fn truncate(&mut self, len: usize) { + if self.len > len { + self.len = len; + } + } + + #[inline] + pub fn reverse(&mut self) { + self.as_mut_slice().reverse() + } + + #[inline] + pub fn into_iter(mut self) -> vec::IntoIter { + self.vec.truncate(self.len); + self.vec.into_iter() + } + + #[inline] + pub fn iter<'a>(&'a self) -> slice::Iter<'a, T> { + self.as_ref().iter() + } + + #[inline] + pub fn iter_mut<'a>(&'a mut self) -> slice::IterMut<'a, T> { + self.as_mut_slice().iter_mut() + } + + #[inline] + pub fn sort_by(&mut self, compare: F) + where + F : Fn(&T, &T) -> Ordering, + { + self.as_mut_slice().sort_by(compare) + } + + #[inline] + pub fn as_ptr(&self) -> *const T { + self.vec.as_ptr() + } + + #[inline] + pub fn as_mut_ptr(&mut self) -> *mut T { + self.vec.as_mut_ptr() + } +} + +impl RepeatedField { + pub fn push_default<'a>(&'a mut self) -> &'a mut T { + if self.len == self.vec.len() { + self.vec.push(Default::default()); + } else { + self.vec[self.len].clear(); + } + self.len += 1; + self.last_mut().unwrap() + } +} + +impl RepeatedField { + // TODO: implement to_vec() + #[inline] + pub fn from_slice(values: &[T]) -> RepeatedField { + RepeatedField::from_vec(values.to_vec()) + } +} + +impl Clone for RepeatedField { + #[inline] + fn clone(&self) -> RepeatedField { + RepeatedField { + vec: self.to_vec(), + len: self.len(), + } + } +} + +impl FromIterator for RepeatedField { + #[inline] + fn from_iter>(iter: I) -> RepeatedField { + RepeatedField::from_vec(FromIterator::from_iter(iter)) + } +} + +impl<'a, T> IntoIterator for &'a RepeatedField { + type Item = &'a T; + type IntoIter = slice::Iter<'a, T>; + + fn into_iter(self) -> slice::Iter<'a, T> { + self.iter() + } +} + +impl PartialEq for RepeatedField { + #[inline] + fn eq(&self, other: &RepeatedField) -> bool { + self.as_ref() == other.as_ref() + } +} + +impl Eq for RepeatedField {} + +impl RepeatedField { + #[inline] + pub fn contains(&self, value: &T) -> bool { + self.as_ref().contains(value) + } +} + +impl Hash for RepeatedField { + fn hash(&self, state: &mut H) { + self.as_ref().hash(state); + } +} + +impl AsRef<[T]> for RepeatedField { + #[inline] + fn as_ref<'a>(&'a self) -> &'a [T] { + &self.vec[..self.len] + } +} + +impl Borrow<[T]> for RepeatedField { + #[inline] + fn borrow(&self) -> &[T] { + &self.vec[..self.len] + } +} + +impl Deref for RepeatedField { + type Target = [T]; + #[inline] + fn deref(&self) -> &[T] { + &self.vec[..self.len] + } +} + +impl DerefMut for RepeatedField { + #[inline] + fn deref_mut(&mut self) -> &mut [T] { + &mut self.vec[..self.len] + } +} + +impl Index for RepeatedField { + type Output = T; + + #[inline] + fn index<'a>(&'a self, index: usize) -> &'a T { + &self.as_ref()[index] + } +} + +impl IndexMut for RepeatedField { + #[inline] + fn index_mut<'a>(&'a mut self, index: usize) -> &'a mut T { + &mut self.as_mut_slice()[index] + } +} + +impl fmt::Debug for RepeatedField { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.as_ref().fmt(f) + } +} + +#[cfg(test)] +mod test { + use super::RepeatedField; + + #[test] + fn as_mut_slice() { + let mut v = RepeatedField::new(); + v.push(10); + v.push(20); + v.clear(); + assert_eq!(v.as_mut_slice(), &mut []); + v.push(30); + assert_eq!(v.as_mut_slice(), &mut [30]); + } + + #[test] + fn push_default() { + let mut v = RepeatedField::new(); + v.push("aa".to_string()); + v.push("bb".to_string()); + v.clear(); + assert_eq!("".to_string(), *v.push_default()); + } +} diff --git a/third_party/protobuf/src/rt.rs b/third_party/protobuf/src/rt.rs new file mode 100644 index 000000000..aa554a941 --- /dev/null +++ b/third_party/protobuf/src/rt.rs @@ -0,0 +1,798 @@ +// Functions used by generated protobuf code. +// Should not be used by programs written by hands. + +use std::default::Default; +use std::hash::Hash; +use std::collections::HashMap; +use std::string::String; +use std::vec::Vec; + +#[cfg(feature = "bytes")] +use bytes::Bytes; +#[cfg(feature = "bytes")] +use chars::Chars; + +use protocore::*; +use zigzag::*; +use stream::wire_format; +use stream::wire_format::WireType; +use stream::wire_format::WireTypeFixed32; +use stream::wire_format::WireTypeFixed64; +use stream::wire_format::WireTypeLengthDelimited; +use stream::wire_format::WireTypeVarint; +use error::ProtobufError; +use error::ProtobufResult; +use error::WireError; +use singular::SingularField; +use singular::SingularPtrField; +use repeated::RepeatedField; +use stream::CodedInputStream; +use stream::CodedOutputStream; +use types::*; + +use unknown::UnknownFields; + + +pub fn compute_raw_varint64_size(value: u64) -> u32 { + if (value & (0xffffffffffffffffu64 << 7)) == 0 { + return 1; + } + if (value & (0xffffffffffffffffu64 << 14)) == 0 { + return 2; + } + if (value & (0xffffffffffffffffu64 << 21)) == 0 { + return 3; + } + if (value & (0xffffffffffffffffu64 << 28)) == 0 { + return 4; + } + if (value & (0xffffffffffffffffu64 << 35)) == 0 { + return 5; + } + if (value & (0xffffffffffffffffu64 << 42)) == 0 { + return 6; + } + if (value & (0xffffffffffffffffu64 << 49)) == 0 { + return 7; + } + if (value & (0xffffffffffffffffu64 << 56)) == 0 { + return 8; + } + if (value & (0xffffffffffffffffu64 << 63)) == 0 { + return 9; + } + 10 +} + +pub fn compute_raw_varint32_size(value: u32) -> u32 { + compute_raw_varint64_size(value as u64) +} + +pub trait ProtobufVarint { + // size of self when written as varint + fn len_varint(&self) -> u32; +} + +pub trait ProtobufVarintZigzag { + fn len_varint_zigzag(&self) -> u32; +} + +impl ProtobufVarint for u64 { + fn len_varint(&self) -> u32 { + compute_raw_varint64_size(*self) + } +} + +impl ProtobufVarint for u32 { + fn len_varint(&self) -> u32 { + (*self as u64).len_varint() + } +} + +impl ProtobufVarint for i64 { + fn len_varint(&self) -> u32 { + // same as length of u64 + (*self as u64).len_varint() + } +} + +impl ProtobufVarintZigzag for i64 { + fn len_varint_zigzag(&self) -> u32 { + compute_raw_varint64_size(encode_zig_zag_64(*self)) + } +} + +impl ProtobufVarint for i32 { + fn len_varint(&self) -> u32 { + // sign-extend and then compute + (*self as i64).len_varint() + } +} + +impl ProtobufVarintZigzag for i32 { + fn len_varint_zigzag(&self) -> u32 { + compute_raw_varint32_size(encode_zig_zag_32(*self)) + } +} + +impl ProtobufVarint for bool { + fn len_varint(&self) -> u32 { + 1 + } +} + +/* Commented out due to https://github.com/mozilla/rust/issues/8075 +impl ProtobufVarint for E { + fn len_varint(&self) -> u32 { + self.value().len_varint() + } +} +*/ + +// Size of serialized data, excluding length and tag +pub fn vec_packed_varint_data_size(vec: &[T]) -> u32 { + vec.iter().map(|v| v.len_varint()).fold(0, |a, i| a + i) +} + +// Size of serialized data, excluding length and tag +pub fn vec_packed_varint_zigzag_data_size(vec: &[T]) -> u32 { + vec.iter() + .map(|v| v.len_varint_zigzag()) + .fold(0, |a, i| a + i) +} + +pub fn vec_packed_enum_data_size(vec: &[E]) -> u32 { + vec.iter() + .map(|e| compute_raw_varint32_size(e.value() as u32)) + .fold(0, |a, i| a + i) +} + +// Size of serialized data with length prefix and tag +pub fn vec_packed_varint_size(field_number: u32, vec: &[T]) -> u32 { + if vec.is_empty() { + 0 + } else { + let data_size = vec_packed_varint_data_size(vec); + tag_size(field_number) + data_size.len_varint() + data_size + } +} + +// Size of serialized data with length prefix and tag +pub fn vec_packed_varint_zigzag_size( + field_number: u32, + vec: &[T], +) -> u32 { + if vec.is_empty() { + 0 + } else { + let data_size = vec_packed_varint_zigzag_data_size(vec); + tag_size(field_number) + data_size.len_varint() + data_size + } +} + +pub fn vec_packed_enum_size(field_number: u32, vec: &[E]) -> u32 { + if vec.is_empty() { + 0 + } else { + let data_size = vec_packed_enum_data_size(vec); + tag_size(field_number) + data_size.len_varint() + data_size + } +} + +// Size of tag does not depend on wire type +pub fn tag_size(field_number: u32) -> u32 { + wire_format::Tag::make(field_number, WireTypeFixed64) + .value() + .len_varint() +} + +pub fn value_size_no_tag(value: T, wt: WireType) -> u32 { + match wt { + WireTypeFixed64 => 8, + WireTypeFixed32 => 4, + WireTypeVarint => value.len_varint(), + _ => panic!(), + } +} + +pub fn value_size(field_number: u32, value: T, wt: WireType) -> u32 { + tag_size(field_number) + value_size_no_tag(value, wt) +} + +/// Length of value when encoded with zigzag encoding +pub fn value_varint_zigzag_size_no_tag(value: T) -> u32 { + value.len_varint_zigzag() +} + +/// Length of value when encoding with zigzag encoding with tag +pub fn value_varint_zigzag_size(field_number: u32, value: T) -> u32 { + tag_size(field_number) + value_varint_zigzag_size_no_tag(value) +} + +fn enum_size_no_tag(value: E) -> u32 { + value.value().len_varint() +} + +pub fn enum_size(field_number: u32, value: E) -> u32 { + tag_size(field_number) + enum_size_no_tag(value) +} + +// TODO: not used in generated code +pub fn bytes_size_no_tag(bytes: &[u8]) -> u32 { + compute_raw_varint64_size(bytes.len() as u64) + bytes.len() as u32 +} + +pub fn bytes_size(field_number: u32, bytes: &[u8]) -> u32 { + tag_size(field_number) + bytes_size_no_tag(bytes) +} + +// TODO: not used in generated code +pub fn string_size_no_tag(s: &str) -> u32 { + bytes_size_no_tag(s.as_bytes()) +} + +pub fn string_size(field_number: u32, s: &str) -> u32 { + tag_size(field_number) + string_size_no_tag(s) +} + +pub fn unknown_fields_size(unknown_fields: &UnknownFields) -> u32 { + let mut r = 0; + for (number, values) in unknown_fields { + r += (tag_size(number) + 4) * values.fixed32.len() as u32; + r += (tag_size(number) + 8) * values.fixed64.len() as u32; + + r += tag_size(number) * values.varint.len() as u32; + for varint in &values.varint { + r += varint.len_varint(); + } + + r += tag_size(number) * values.length_delimited.len() as u32; + for bytes in &values.length_delimited { + r += bytes_size_no_tag(&bytes); + } + } + r +} + + +pub fn read_repeated_int32_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_repeated_packed_int32_into(target), + WireTypeVarint => { + target.push(is.read_int32()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_int64_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_repeated_packed_int64_into(target), + WireTypeVarint => { + target.push(is.read_int64()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_uint32_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_repeated_packed_uint32_into(target), + WireTypeVarint => { + target.push(is.read_uint32()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_uint64_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_repeated_packed_uint64_into(target), + WireTypeVarint => { + target.push(is.read_uint64()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_sint32_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_repeated_packed_sint32_into(target), + WireTypeVarint => { + target.push(is.read_sint32()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_sint64_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_repeated_packed_sint64_into(target), + WireTypeVarint => { + target.push(is.read_sint64()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_fixed32_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_repeated_packed_fixed32_into(target), + WireTypeFixed32 => { + target.push(is.read_fixed32()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_fixed64_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_repeated_packed_fixed64_into(target), + WireTypeFixed64 => { + target.push(is.read_fixed64()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_sfixed32_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_repeated_packed_sfixed32_into(target), + WireTypeFixed32 => { + target.push(is.read_sfixed32()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_sfixed64_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_repeated_packed_sfixed64_into(target), + WireTypeFixed64 => { + target.push(is.read_sfixed64()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_double_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_repeated_packed_double_into(target), + WireTypeFixed64 => { + target.push(is.read_double()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_float_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_repeated_packed_float_into(target), + WireTypeFixed32 => { + target.push(is.read_float()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_bool_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_repeated_packed_bool_into(target), + WireTypeVarint => { + target.push(is.read_bool()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_enum_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_repeated_packed_enum_into(target), + WireTypeVarint => { + target.push(is.read_enum()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_string_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut RepeatedField, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => { + let tmp = target.push_default(); + is.read_string_into(tmp) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +#[cfg(feature = "bytes")] +pub fn read_repeated_carllerche_string_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => { + target.push(is.read_carllerche_chars()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_singular_string_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut SingularField, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => { + let tmp = target.set_default(); + is.read_string_into(tmp) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +#[cfg(feature = "bytes")] +pub fn read_singular_carllerche_string_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Option, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => { + *target = Some(is.read_carllerche_chars()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_singular_proto3_string_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut String, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_string_into(target), + _ => Err(unexpected_wire_type(wire_type)), + } +} + +#[cfg(feature = "bytes")] +pub fn read_singular_proto3_carllerche_string_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Chars, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => { + *target = is.read_carllerche_chars()?; + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_bytes_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut RepeatedField>, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => { + let tmp = target.push_default(); + is.read_bytes_into(tmp) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +#[cfg(feature = "bytes")] +pub fn read_repeated_carllerche_bytes_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => { + target.push(is.read_carllerche_bytes()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_singular_bytes_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut SingularField>, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => { + let tmp = target.set_default(); + is.read_bytes_into(tmp) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +#[cfg(feature = "bytes")] +pub fn read_singular_carllerche_bytes_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Option, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => { + *target = Some(is.read_carllerche_bytes()?); + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_singular_proto3_bytes_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Vec, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => is.read_bytes_into(target), + _ => Err(unexpected_wire_type(wire_type)), + } +} + +#[cfg(feature = "bytes")] +pub fn read_singular_proto3_carllerche_bytes_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut Bytes, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => { + *target = is.read_carllerche_bytes()?; + Ok(()) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_repeated_message_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut RepeatedField, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => { + let tmp = target.push_default(); + is.merge_message(tmp) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +pub fn read_singular_message_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut SingularPtrField, +) -> ProtobufResult<()> { + match wire_type { + WireTypeLengthDelimited => { + let tmp = target.set_default(); + is.merge_message(tmp) + } + _ => Err(unexpected_wire_type(wire_type)), + } +} + +fn skip_group(is: &mut CodedInputStream) -> ProtobufResult<()> { + loop { + let (_, wire_type) = is.read_tag_unpack()?; + if wire_type == wire_format::WireTypeEndGroup { + return Ok(()); + } + is.skip_field(wire_type)?; + } +} + +// Handle unknown field in generated code. +// Either store a value in unknown, or skip a group. +pub fn read_unknown_or_skip_group( + field_number: u32, + wire_type: WireType, + is: &mut CodedInputStream, + unknown_fields: &mut UnknownFields, +) -> ProtobufResult<()> { + match wire_type { + wire_format::WireTypeStartGroup => skip_group(is), + _ => { + let unknown = is.read_unknown(wire_type)?; + unknown_fields.add_value(field_number, unknown); + Ok(()) + } + } +} + + +/// Create an error for unexpected wire type. +/// +/// Function is used in generated code, so error types can be changed, +/// but this function remains unchanged. +pub fn unexpected_wire_type(wire_type: WireType) -> ProtobufError { + ProtobufError::WireError(WireError::UnexpectedWireType(wire_type)) +} + + + +pub fn compute_map_size(field_number: u32, map: &HashMap) -> u32 +where + K : ProtobufType, + V : ProtobufType, + K::Value : Eq + Hash, +{ + let mut sum = 0; + for (k, v) in map { + let key_tag_size = 1; + let value_tag_size = 1; + + let key_len = K::compute_size_with_length_delimiter(k); + let value_len = V::compute_size_with_length_delimiter(v); + + let entry_len = key_tag_size + key_len + value_tag_size + value_len; + sum += tag_size(field_number) + compute_raw_varint32_size(entry_len) + entry_len; + } + sum +} + +pub fn write_map_with_cached_sizes( + field_number: u32, + map: &HashMap, + os: &mut CodedOutputStream, +) -> ProtobufResult<()> +where + K : ProtobufType, + V : ProtobufType, + K::Value : Eq + Hash, +{ + for (k, v) in map { + + let key_tag_size = 1; + let value_tag_size = 1; + + let key_len = K::get_cached_size_with_length_delimiter(k); + let value_len = V::get_cached_size_with_length_delimiter(v); + + let entry_len = key_tag_size + key_len + value_tag_size + value_len; + + os.write_tag(field_number, WireType::WireTypeLengthDelimited)?; + os.write_raw_varint32(entry_len)?; + K::write_with_cached_size(1, k, os)?; + V::write_with_cached_size(2, v, os)?; + } + Ok(()) +} + +pub fn read_map_into( + wire_type: WireType, + is: &mut CodedInputStream, + target: &mut HashMap, +) -> ProtobufResult<()> +where + K : ProtobufType, + V : ProtobufType, + K::Value : Eq + Hash, +{ + if wire_type != WireType::WireTypeLengthDelimited { + return Err(unexpected_wire_type(wire_type)); + } + + let mut key = None; + let mut value = None; + + let len = is.read_raw_varint32()?; + let old_limit = is.push_limit(len as u64)?; + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != K::wire_type() { + return Err(unexpected_wire_type(wire_type)); + } + key = Some(K::read(is)?); + } + 2 => { + if wire_type != V::wire_type() { + return Err(unexpected_wire_type(wire_type)); + } + value = Some(V::read(is)?); + } + _ => is.skip_field(wire_type)?, + } + } + is.pop_limit(old_limit); + + match (key, value) { + (None, _) | (_, None) => return Err(ProtobufError::WireError(WireError::IncompleteMap)), + (Some(key), Some(value)) => { + target.insert(key, value); + } + } + + Ok(()) +} diff --git a/third_party/protobuf/src/rust.rs b/third_party/protobuf/src/rust.rs new file mode 100644 index 000000000..dc72f84f8 --- /dev/null +++ b/third_party/protobuf/src/rust.rs @@ -0,0 +1,123 @@ +use std::string::String; + +static RUST_KEYWORDS: &'static [&'static str] = &[ + "as", + "break", + "crate", + "else", + "enum", + "extern", + "false", + "fn", + "for", + "if", + "impl", + "in", + "let", + "loop", + "match", + "mod", + "move", + "mut", + "pub", + "ref", + "return", + "static", + "self", + "Self", + "struct", + "super", + "true", + "trait", + "type", + "unsafe", + "use", + "while", + "continue", + "box", + "const", + "where", + "virtual", + "proc", + "alignof", + "become", + "offsetof", + "priv", + "pure", + "sizeof", + "typeof", + "unsized", + "yield", + "do", + "abstract", + "final", + "override", + "macro", +]; + +pub fn is_rust_keyword(ident: &str) -> bool { + RUST_KEYWORDS.contains(&ident) +} + +#[allow(dead_code)] +fn hex_digit(value: u32) -> char { + if value < 10 { + (b'0' + value as u8) as char + } else if value < 0x10 { + (b'a' + value as u8 - 10) as char + } else { + unreachable!() + } +} + +#[allow(dead_code)] +pub fn quote_escape_str(s: &str) -> String { + let mut buf = String::new(); + buf.push('"'); + buf.extend(s.chars().flat_map(|c| c.escape_default())); + buf.push('"'); + buf +} + +#[allow(dead_code)] +pub fn quote_escape_bytes(bytes: &[u8]) -> String { + let mut buf = String::new(); + buf.push('b'); + buf.push('"'); + for &b in bytes { + match b { + b'\n' => buf.push_str(r"\n"), + b'\r' => buf.push_str(r"\r"), + b'\t' => buf.push_str(r"\t"), + b'"' => buf.push_str("\\\""), + b'\\' => buf.push_str(r"\\"), + b'\x20'...b'\x7e' => buf.push(b as char), + _ => { + buf.push_str(r"\x"); + buf.push(hex_digit((b as u32) >> 4)); + buf.push(hex_digit((b as u32) & 0x0f)); + } + } + } + buf.push('"'); + buf +} + +#[cfg(test)] +mod test { + + use super::*; + + #[test] + fn test_quote_escape_bytes() { + assert_eq!("b\"\"", quote_escape_bytes(b"")); + assert_eq!("b\"xyZW\"", quote_escape_bytes(b"xyZW")); + assert_eq!("b\"aa\\\"bb\"", quote_escape_bytes(b"aa\"bb")); + assert_eq!("b\"aa\\r\\n\\tbb\"", quote_escape_bytes(b"aa\r\n\tbb")); + assert_eq!( + "b\"\\x00\\x01\\x12\\xfe\\xff\"", + quote_escape_bytes(b"\x00\x01\x12\xfe\xff") + ); + } + +} diff --git a/third_party/protobuf/src/rustproto.rs b/third_party/protobuf/src/rustproto.rs new file mode 100644 index 000000000..6c6070b73 --- /dev/null +++ b/third_party/protobuf/src/rustproto.rs @@ -0,0 +1,164 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +pub mod exts { + use protobuf::Message as Message_imported_for_functions; + + pub const expose_oneof_all: ::protobuf::ext::ExtFieldOptional = ::protobuf::ext::ExtFieldOptional { field_number: 17001, phantom: ::std::marker::PhantomData }; + + pub const expose_fields_all: ::protobuf::ext::ExtFieldOptional = ::protobuf::ext::ExtFieldOptional { field_number: 17003, phantom: ::std::marker::PhantomData }; + + pub const generate_accessors_all: ::protobuf::ext::ExtFieldOptional = ::protobuf::ext::ExtFieldOptional { field_number: 17004, phantom: ::std::marker::PhantomData }; + + pub const carllerche_bytes_for_bytes_all: ::protobuf::ext::ExtFieldOptional = ::protobuf::ext::ExtFieldOptional { field_number: 17011, phantom: ::std::marker::PhantomData }; + + pub const carllerche_bytes_for_string_all: ::protobuf::ext::ExtFieldOptional = ::protobuf::ext::ExtFieldOptional { field_number: 17012, phantom: ::std::marker::PhantomData }; + + pub const expose_oneof: ::protobuf::ext::ExtFieldOptional = ::protobuf::ext::ExtFieldOptional { field_number: 17001, phantom: ::std::marker::PhantomData }; + + pub const expose_fields: ::protobuf::ext::ExtFieldOptional = ::protobuf::ext::ExtFieldOptional { field_number: 17003, phantom: ::std::marker::PhantomData }; + + pub const generate_accessors: ::protobuf::ext::ExtFieldOptional = ::protobuf::ext::ExtFieldOptional { field_number: 17004, phantom: ::std::marker::PhantomData }; + + pub const carllerche_bytes_for_bytes: ::protobuf::ext::ExtFieldOptional = ::protobuf::ext::ExtFieldOptional { field_number: 17011, phantom: ::std::marker::PhantomData }; + + pub const carllerche_bytes_for_string: ::protobuf::ext::ExtFieldOptional = ::protobuf::ext::ExtFieldOptional { field_number: 17012, phantom: ::std::marker::PhantomData }; + + pub const expose_fields_field: ::protobuf::ext::ExtFieldOptional = ::protobuf::ext::ExtFieldOptional { field_number: 17003, phantom: ::std::marker::PhantomData }; + + pub const generate_accessors_field: ::protobuf::ext::ExtFieldOptional = ::protobuf::ext::ExtFieldOptional { field_number: 17004, phantom: ::std::marker::PhantomData }; + + pub const carllerche_bytes_for_bytes_field: ::protobuf::ext::ExtFieldOptional = ::protobuf::ext::ExtFieldOptional { field_number: 17011, phantom: ::std::marker::PhantomData }; + + pub const carllerche_bytes_for_string_field: ::protobuf::ext::ExtFieldOptional = ::protobuf::ext::ExtFieldOptional { field_number: 17012, phantom: ::std::marker::PhantomData }; +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x0frustproto.proto\x12\trustproto\x1a\x20google/protobuf/descriptor.p\ + roto:H\n\x10expose_oneof_all\x18\xe9\x84\x01\x20\x01(\x08\x12\x1c.google\ + .protobuf.FileOptionsR\x0eexposeOneofAll:J\n\x11expose_fields_all\x18\ + \xeb\x84\x01\x20\x01(\x08\x12\x1c.google.protobuf.FileOptionsR\x0fexpose\ + FieldsAll:T\n\x16generate_accessors_all\x18\xec\x84\x01\x20\x01(\x08\x12\ + \x1c.google.protobuf.FileOptionsR\x14generateAccessorsAll:b\n\x1ecarller\ + che_bytes_for_bytes_all\x18\xf3\x84\x01\x20\x01(\x08\x12\x1c.google.prot\ + obuf.FileOptionsR\x1acarllercheBytesForBytesAll:d\n\x1fcarllerche_bytes_\ + for_string_all\x18\xf4\x84\x01\x20\x01(\x08\x12\x1c.google.protobuf.File\ + OptionsR\x1bcarllercheBytesForStringAll:D\n\x0cexpose_oneof\x18\xe9\x84\ + \x01\x20\x01(\x08\x12\x1f.google.protobuf.MessageOptionsR\x0bexposeOneof\ + :F\n\rexpose_fields\x18\xeb\x84\x01\x20\x01(\x08\x12\x1f.google.protobuf\ + .MessageOptionsR\x0cexposeFields:P\n\x12generate_accessors\x18\xec\x84\ + \x01\x20\x01(\x08\x12\x1f.google.protobuf.MessageOptionsR\x11generateAcc\ + essors:^\n\x1acarllerche_bytes_for_bytes\x18\xf3\x84\x01\x20\x01(\x08\ + \x12\x1f.google.protobuf.MessageOptionsR\x17carllercheBytesForBytes:`\n\ + \x1bcarllerche_bytes_for_string\x18\xf4\x84\x01\x20\x01(\x08\x12\x1f.goo\ + gle.protobuf.MessageOptionsR\x18carllercheBytesForString:O\n\x13expose_f\ + ields_field\x18\xeb\x84\x01\x20\x01(\x08\x12\x1d.google.protobuf.FieldOp\ + tionsR\x11exposeFieldsField:Y\n\x18generate_accessors_field\x18\xec\x84\ + \x01\x20\x01(\x08\x12\x1d.google.protobuf.FieldOptionsR\x16generateAcces\ + sorsField:g\n\x20carllerche_bytes_for_bytes_field\x18\xf3\x84\x01\x20\ + \x01(\x08\x12\x1d.google.protobuf.FieldOptionsR\x1ccarllercheBytesForByt\ + esField:i\n!carllerche_bytes_for_string_field\x18\xf4\x84\x01\x20\x01(\ + \x08\x12\x1d.google.protobuf.FieldOptionsR\x1dcarllercheBytesForStringFi\ + eldJ\xf4\x0e\n\x06\x12\x04\0\0,\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\t\ + \n\x02\x03\0\x12\x03\x02\x07)\nh\n\x01\x02\x12\x03\x07\x08\x112^\x20see\ + \x20https://github.com/gogo/protobuf/blob/master/gogoproto/gogo.proto\n\ + \x20for\x20the\x20original\x20idea\n\n\t\n\x01\x07\x12\x04\t\0\x14\x01\n\ + 7\n\x02\x07\0\x12\x03\x0b\x04+\x1a,\x20When\x20true,\x20oneof\x20field\ + \x20is\x20generated\x20public\n\n\n\n\x03\x07\0\x02\x12\x03\t\x07\"\n\n\ + \n\x03\x07\0\x04\x12\x03\x0b\x04\x0c\n\n\n\x03\x07\0\x05\x12\x03\x0b\r\ + \x11\n\n\n\x03\x07\0\x01\x12\x03\x0b\x12\"\n\n\n\x03\x07\0\x03\x12\x03\ + \x0b%*\nI\n\x02\x07\x01\x12\x03\r\x04,\x1a>\x20When\x20true\x20all\x20fi\ + elds\x20are\x20public,\x20and\x20not\x20accessors\x20generated\n\n\n\n\ + \x03\x07\x01\x02\x12\x03\t\x07\"\n\n\n\x03\x07\x01\x04\x12\x03\r\x04\x0c\ + \n\n\n\x03\x07\x01\x05\x12\x03\r\r\x11\n\n\n\x03\x07\x01\x01\x12\x03\r\ + \x12#\n\n\n\x03\x07\x01\x03\x12\x03\r&+\nP\n\x02\x07\x02\x12\x03\x0f\x04\ + 1\x1aE\x20When\x20false,\x20`get_`,\x20`set_`,\x20`mut_`\x20etc.\x20acce\ + ssors\x20are\x20not\x20generated\n\n\n\n\x03\x07\x02\x02\x12\x03\t\x07\"\ + \n\n\n\x03\x07\x02\x04\x12\x03\x0f\x04\x0c\n\n\n\x03\x07\x02\x05\x12\x03\ + \x0f\r\x11\n\n\n\x03\x07\x02\x01\x12\x03\x0f\x12(\n\n\n\x03\x07\x02\x03\ + \x12\x03\x0f+0\n2\n\x02\x07\x03\x12\x03\x11\x049\x1a'\x20Use\x20`bytes::\ + Bytes`\x20for\x20`bytes`\x20fields\n\n\n\n\x03\x07\x03\x02\x12\x03\t\x07\ + \"\n\n\n\x03\x07\x03\x04\x12\x03\x11\x04\x0c\n\n\n\x03\x07\x03\x05\x12\ + \x03\x11\r\x11\n\n\n\x03\x07\x03\x01\x12\x03\x11\x120\n\n\n\x03\x07\x03\ + \x03\x12\x03\x1138\n3\n\x02\x07\x04\x12\x03\x13\x04:\x1a(\x20Use\x20`byt\ + es::Bytes`\x20for\x20`string`\x20fields\n\n\n\n\x03\x07\x04\x02\x12\x03\ + \t\x07\"\n\n\n\x03\x07\x04\x04\x12\x03\x13\x04\x0c\n\n\n\x03\x07\x04\x05\ + \x12\x03\x13\r\x11\n\n\n\x03\x07\x04\x01\x12\x03\x13\x121\n\n\n\x03\x07\ + \x04\x03\x12\x03\x1349\n\t\n\x01\x07\x12\x04\x16\0!\x01\n7\n\x02\x07\x05\ + \x12\x03\x18\x04'\x1a,\x20When\x20true,\x20oneof\x20field\x20is\x20gener\ + ated\x20public\n\n\n\n\x03\x07\x05\x02\x12\x03\x16\x07%\n\n\n\x03\x07\ + \x05\x04\x12\x03\x18\x04\x0c\n\n\n\x03\x07\x05\x05\x12\x03\x18\r\x11\n\n\ + \n\x03\x07\x05\x01\x12\x03\x18\x12\x1e\n\n\n\x03\x07\x05\x03\x12\x03\x18\ + !&\nI\n\x02\x07\x06\x12\x03\x1a\x04(\x1a>\x20When\x20true\x20all\x20fiel\ + ds\x20are\x20public,\x20and\x20not\x20accessors\x20generated\n\n\n\n\x03\ + \x07\x06\x02\x12\x03\x16\x07%\n\n\n\x03\x07\x06\x04\x12\x03\x1a\x04\x0c\ + \n\n\n\x03\x07\x06\x05\x12\x03\x1a\r\x11\n\n\n\x03\x07\x06\x01\x12\x03\ + \x1a\x12\x1f\n\n\n\x03\x07\x06\x03\x12\x03\x1a\"'\nP\n\x02\x07\x07\x12\ + \x03\x1c\x04-\x1aE\x20When\x20false,\x20`get_`,\x20`set_`,\x20`mut_`\x20\ + etc.\x20accessors\x20are\x20not\x20generated\n\n\n\n\x03\x07\x07\x02\x12\ + \x03\x16\x07%\n\n\n\x03\x07\x07\x04\x12\x03\x1c\x04\x0c\n\n\n\x03\x07\ + \x07\x05\x12\x03\x1c\r\x11\n\n\n\x03\x07\x07\x01\x12\x03\x1c\x12$\n\n\n\ + \x03\x07\x07\x03\x12\x03\x1c',\n2\n\x02\x07\x08\x12\x03\x1e\x045\x1a'\ + \x20Use\x20`bytes::Bytes`\x20for\x20`bytes`\x20fields\n\n\n\n\x03\x07\ + \x08\x02\x12\x03\x16\x07%\n\n\n\x03\x07\x08\x04\x12\x03\x1e\x04\x0c\n\n\ + \n\x03\x07\x08\x05\x12\x03\x1e\r\x11\n\n\n\x03\x07\x08\x01\x12\x03\x1e\ + \x12,\n\n\n\x03\x07\x08\x03\x12\x03\x1e/4\n3\n\x02\x07\t\x12\x03\x20\x04\ + 6\x1a(\x20Use\x20`bytes::Bytes`\x20for\x20`string`\x20fields\n\n\n\n\x03\ + \x07\t\x02\x12\x03\x16\x07%\n\n\n\x03\x07\t\x04\x12\x03\x20\x04\x0c\n\n\ + \n\x03\x07\t\x05\x12\x03\x20\r\x11\n\n\n\x03\x07\t\x01\x12\x03\x20\x12-\ + \n\n\n\x03\x07\t\x03\x12\x03\x2005\n\t\n\x01\x07\x12\x04#\0,\x01\nI\n\ + \x02\x07\n\x12\x03%\x04.\x1a>\x20When\x20true\x20all\x20fields\x20are\ + \x20public,\x20and\x20not\x20accessors\x20generated\n\n\n\n\x03\x07\n\ + \x02\x12\x03#\x07#\n\n\n\x03\x07\n\x04\x12\x03%\x04\x0c\n\n\n\x03\x07\n\ + \x05\x12\x03%\r\x11\n\n\n\x03\x07\n\x01\x12\x03%\x12%\n\n\n\x03\x07\n\ + \x03\x12\x03%(-\nP\n\x02\x07\x0b\x12\x03'\x043\x1aE\x20When\x20false,\ + \x20`get_`,\x20`set_`,\x20`mut_`\x20etc.\x20accessors\x20are\x20not\x20g\ + enerated\n\n\n\n\x03\x07\x0b\x02\x12\x03#\x07#\n\n\n\x03\x07\x0b\x04\x12\ + \x03'\x04\x0c\n\n\n\x03\x07\x0b\x05\x12\x03'\r\x11\n\n\n\x03\x07\x0b\x01\ + \x12\x03'\x12*\n\n\n\x03\x07\x0b\x03\x12\x03'-2\n2\n\x02\x07\x0c\x12\x03\ + )\x04;\x1a'\x20Use\x20`bytes::Bytes`\x20for\x20`bytes`\x20fields\n\n\n\n\ + \x03\x07\x0c\x02\x12\x03#\x07#\n\n\n\x03\x07\x0c\x04\x12\x03)\x04\x0c\n\ + \n\n\x03\x07\x0c\x05\x12\x03)\r\x11\n\n\n\x03\x07\x0c\x01\x12\x03)\x122\ + \n\n\n\x03\x07\x0c\x03\x12\x03)5:\n3\n\x02\x07\r\x12\x03+\x04<\x1a(\x20U\ + se\x20`bytes::Bytes`\x20for\x20`string`\x20fields\n\n\n\n\x03\x07\r\x02\ + \x12\x03#\x07#\n\n\n\x03\x07\r\x04\x12\x03+\x04\x0c\n\n\n\x03\x07\r\x05\ + \x12\x03+\r\x11\n\n\n\x03\x07\r\x01\x12\x03+\x123\n\n\n\x03\x07\r\x03\ + \x12\x03+6;\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/third_party/protobuf/src/singular.rs b/third_party/protobuf/src/singular.rs new file mode 100644 index 000000000..12f3ee1d3 --- /dev/null +++ b/third_party/protobuf/src/singular.rs @@ -0,0 +1,448 @@ +use std::hash::Hash; +use std::hash::Hasher; +use std::option; +use std::default::Default; +use std::fmt; +use std::mem; +use std::boxed::Box; + +use clear::Clear; + + +pub struct SingularField { + value: T, + set: bool, +} + +pub struct SingularPtrField { + value: Option>, + set: bool, +} + +impl SingularField { + #[inline] + pub fn some(value: T) -> SingularField { + SingularField { + value: value, + set: true, + } + } + + #[inline] + pub fn is_some(&self) -> bool { + self.set + } + + #[inline] + pub fn is_none(&self) -> bool { + !self.is_some() + } + + #[inline] + pub fn into_option(self) -> Option { + if self.set { Some(self.value) } else { None } + } + + #[inline] + pub fn as_ref<'a>(&'a self) -> Option<&'a T> { + if self.set { Some(&self.value) } else { None } + } + + #[inline] + pub fn as_mut<'a>(&'a mut self) -> Option<&'a mut T> { + if self.set { + Some(&mut self.value) + } else { + None + } + } + + #[inline] + pub fn get_ref<'a>(&'a self) -> &'a T { + self.as_ref().unwrap() + } + + #[inline] + pub fn get_mut_ref<'a>(&'a mut self) -> &'a mut T { + self.as_mut().unwrap() + } + + #[inline] + pub fn unwrap(self) -> T { + if self.set { + self.value + } else { + panic!(); + } + } + + #[inline] + pub fn unwrap_or(self, def: T) -> T { + if self.set { self.value } else { def } + } + + #[inline] + pub fn unwrap_or_else(self, f: F) -> T + where + F : FnOnce() -> T, + { + if self.set { self.value } else { f() } + } + + #[inline] + pub fn map(self, f: F) -> SingularPtrField + where + F : FnOnce(T) -> U, + { + SingularPtrField::from_option(self.into_option().map(f)) + } + + #[inline] + pub fn iter<'a>(&'a self) -> option::IntoIter<&'a T> { + self.as_ref().into_iter() + } + + #[inline] + pub fn mut_iter<'a>(&'a mut self) -> option::IntoIter<&'a mut T> { + self.as_mut().into_iter() + } + + #[inline] + pub fn clear(&mut self) { + self.set = false; + } +} + +impl SingularField { + #[inline] + pub fn none() -> SingularField { + SingularField { + value: Default::default(), + set: false, + } + } + + #[inline] + pub fn from_option(option: Option) -> SingularField { + match option { + Some(x) => SingularField::some(x), + None => SingularField::none(), + } + } + + #[inline] + pub fn take(&mut self) -> Option { + if self.set { + self.set = false; + Some(mem::replace(&mut self.value, Default::default())) + } else { + None + } + } +} + +impl SingularPtrField { + #[inline] + pub fn some(value: T) -> SingularPtrField { + SingularPtrField { + value: Some(Box::new(value)), + set: true, + } + } + + #[inline] + pub fn none() -> SingularPtrField { + SingularPtrField { + value: None, + set: false, + } + } + + #[inline] + pub fn from_option(option: Option) -> SingularPtrField { + match option { + Some(x) => SingularPtrField::some(x), + None => SingularPtrField::none(), + } + } + + #[inline] + pub fn is_some(&self) -> bool { + self.set + } + + #[inline] + pub fn is_none(&self) -> bool { + !self.is_some() + } + + #[inline] + pub fn into_option(self) -> Option { + if self.set { + Some(*self.value.unwrap()) + } else { + None + } + } + + #[inline] + pub fn as_ref<'a>(&'a self) -> Option<&'a T> { + if self.set { + Some(&**self.value.as_ref().unwrap()) + } else { + None + } + } + + #[inline] + pub fn as_mut<'a>(&'a mut self) -> Option<&'a mut T> { + if self.set { + Some(&mut **self.value.as_mut().unwrap()) + } else { + None + } + } + + #[inline] + pub fn get_ref<'a>(&'a self) -> &'a T { + self.as_ref().unwrap() + } + + #[inline] + pub fn get_mut_ref<'a>(&'a mut self) -> &'a mut T { + self.as_mut().unwrap() + } + + #[inline] + pub fn unwrap(self) -> T { + if self.set { + *self.value.unwrap() + } else { + panic!(); + } + } + + #[inline] + pub fn unwrap_or(self, def: T) -> T { + if self.set { *self.value.unwrap() } else { def } + } + + #[inline] + pub fn unwrap_or_else(self, f: F) -> T + where + F : FnOnce() -> T, + { + if self.set { *self.value.unwrap() } else { f() } + } + + #[inline] + pub fn map(self, f: F) -> SingularPtrField + where + F : FnOnce(T) -> U, + { + SingularPtrField::from_option(self.into_option().map(f)) + } + + #[inline] + pub fn iter<'a>(&'a self) -> option::IntoIter<&'a T> { + self.as_ref().into_iter() + } + + #[inline] + pub fn mut_iter<'a>(&'a mut self) -> option::IntoIter<&'a mut T> { + self.as_mut().into_iter() + } + + #[inline] + pub fn take(&mut self) -> Option { + if self.set { + self.set = false; + Some(*self.value.take().unwrap()) + } else { + None + } + } + + #[inline] + pub fn clear(&mut self) { + self.set = false; + } +} + +impl SingularField { + #[inline] + pub fn unwrap_or_default(mut self) -> T { + self.value.clear(); + self.value + } + + #[inline] + pub fn set_default<'a>(&'a mut self) -> &'a mut T { + self.set = true; + self.value.clear(); + &mut self.value + } +} + +impl SingularPtrField { + #[inline] + pub fn unwrap_or_default(mut self) -> T { + if self.set { + self.unwrap() + } else if self.value.is_some() { + self.value.clear(); + *self.value.unwrap() + } else { + Default::default() + } + } + + #[inline] + pub fn set_default<'a>(&'a mut self) -> &'a mut T { + self.set = true; + if self.value.is_some() { + self.value.as_mut().unwrap().clear(); + } else { + self.value = Some(Default::default()); + } + self.as_mut().unwrap() + } +} + +impl Default for SingularField { + #[inline] + fn default() -> SingularField { + SingularField::none() + } +} + +impl Default for SingularPtrField { + #[inline] + fn default() -> SingularPtrField { + SingularPtrField::none() + } +} + +impl Clone for SingularField { + #[inline] + fn clone(&self) -> SingularField { + if self.set { + SingularField::some(self.value.clone()) + } else { + SingularField::none() + } + } +} + +impl Clone for SingularPtrField { + #[inline] + fn clone(&self) -> SingularPtrField { + if self.set { + SingularPtrField::some(self.as_ref().unwrap().clone()) + } else { + SingularPtrField::none() + } + } +} + +impl fmt::Debug for SingularField { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.is_some() { + write!(f, "Some({:?})", *self.as_ref().unwrap()) + } else { + write!(f, "None") + } + } +} + +impl fmt::Debug for SingularPtrField { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.is_some() { + write!(f, "Some({:?})", *self.as_ref().unwrap()) + } else { + write!(f, "None") + } + } +} + +impl PartialEq for SingularField { + #[inline] + fn eq(&self, other: &SingularField) -> bool { + self.as_ref() == other.as_ref() + } +} + +impl Eq for SingularField {} + +impl PartialEq for SingularPtrField { + #[inline] + fn eq(&self, other: &SingularPtrField) -> bool { + self.as_ref() == other.as_ref() + } +} + +impl Eq for SingularPtrField {} + + +impl Hash for SingularField { + fn hash(&self, state: &mut H) { + self.as_ref().hash(state); + } +} + +impl Hash for SingularPtrField { + fn hash(&self, state: &mut H) { + self.as_ref().hash(state); + } +} + +impl<'a, T> IntoIterator for &'a SingularField { + type Item = &'a T; + type IntoIter = option::IntoIter<&'a T>; + + fn into_iter(self) -> option::IntoIter<&'a T> { + self.iter() + } +} + +impl<'a, T> IntoIterator for &'a SingularPtrField { + type Item = &'a T; + type IntoIter = option::IntoIter<&'a T>; + + fn into_iter(self) -> option::IntoIter<&'a T> { + self.iter() + } +} + + +#[cfg(test)] +mod test { + use clear::Clear; + use super::SingularField; + + #[test] + fn test_set_default_clears() { + #[derive(Default)] + struct Foo { + b: isize, + } + + impl Clear for Foo { + fn clear(&mut self) { + self.b = 0; + } + } + + let mut x = SingularField::some(Foo { b: 10 }); + x.clear(); + x.set_default(); + assert_eq!(0, x.as_ref().unwrap().b); + + x.as_mut().unwrap().b = 11; + // without clear + x.set_default(); + assert_eq!(0, x.as_ref().unwrap().b); + } +} diff --git a/third_party/protobuf/src/stream.rs b/third_party/protobuf/src/stream.rs new file mode 100644 index 000000000..bd3755282 --- /dev/null +++ b/third_party/protobuf/src/stream.rs @@ -0,0 +1,1475 @@ +use std::mem; +use std::io::{BufRead, Read}; +use std::io::Write; +use std::slice; +use std::string::String; +use std::vec::Vec; + +#[cfg(feature = "bytes")] +use bytes::Bytes; +#[cfg(feature = "bytes")] +use chars::Chars; + +use varint; +use misc::remaining_capacity_as_slice_mut; +use misc::remove_lifetime_mut; +use protocore::Message; +use protocore::MessageStatic; +use protocore::ProtobufEnum; +use unknown::UnknownFields; +use unknown::UnknownValue; +use unknown::UnknownValueRef; +use zigzag::decode_zig_zag_32; +use zigzag::decode_zig_zag_64; +use zigzag::encode_zig_zag_32; +use zigzag::encode_zig_zag_64; +use error::ProtobufResult; +use error::ProtobufError; +use error::WireError; +use buf_read_iter::BufReadIter; + +// Equal to the default buffer size of `BufWriter`, so when +// `CodedOutputStream` wraps `BufWriter`, it often skips double buffering. +const OUTPUT_STREAM_BUFFER_SIZE: usize = 8 * 1024; + + +pub mod wire_format { + // TODO: temporary + pub use self::WireType::*; + + pub const TAG_TYPE_BITS: u32 = 3; + pub const TAG_TYPE_MASK: u32 = (1u32 << TAG_TYPE_BITS as usize) - 1; + // max possible tag number + pub const FIELD_NUMBER_MAX: u32 = 0x1fffffff; + + #[derive(PartialEq, Eq, Clone, Debug)] + pub enum WireType { + WireTypeVarint = 0, + WireTypeFixed64 = 1, + WireTypeLengthDelimited = 2, + WireTypeStartGroup = 3, + WireTypeEndGroup = 4, + WireTypeFixed32 = 5, + } + + impl Copy for WireType {} + + impl WireType { + pub fn new(n: u32) -> Option { + match n { + 0 => Some(WireTypeVarint), + 1 => Some(WireTypeFixed64), + 2 => Some(WireTypeLengthDelimited), + 3 => Some(WireTypeStartGroup), + 4 => Some(WireTypeEndGroup), + 5 => Some(WireTypeFixed32), + _ => None, + } + } + } + + #[derive(Clone)] + pub struct Tag { + field_number: u32, + wire_type: WireType, + } + + impl Copy for Tag {} + + impl Tag { + pub fn value(self) -> u32 { + (self.field_number << TAG_TYPE_BITS) | (self.wire_type as u32) + } + + // TODO: should return Result instead of Option + pub fn new(value: u32) -> Option { + let wire_type = WireType::new(value & TAG_TYPE_MASK); + if wire_type.is_none() { + return None; + } + let field_number = value >> TAG_TYPE_BITS; + if field_number == 0 { + return None; + } + Some(Tag { + field_number: field_number, + wire_type: wire_type.unwrap(), + }) + } + + pub fn make(field_number: u32, wire_type: WireType) -> Tag { + assert!(field_number > 0 && field_number <= FIELD_NUMBER_MAX); + Tag { + field_number: field_number, + wire_type: wire_type, + } + } + + pub fn unpack(self) -> (u32, WireType) { + (self.field_number(), self.wire_type()) + } + + fn wire_type(self) -> WireType { + self.wire_type + } + + pub fn field_number(self) -> u32 { + self.field_number + } + } + +} + +pub struct CodedInputStream<'a> { + source: BufReadIter<'a>, +} + +impl<'a> CodedInputStream<'a> { + pub fn new(read: &'a mut Read) -> CodedInputStream<'a> { + CodedInputStream { source: BufReadIter::from_read(read) } + } + + pub fn from_buffered_reader(buf_read: &'a mut BufRead) -> CodedInputStream<'a> { + CodedInputStream { source: BufReadIter::from_buf_read(buf_read) } + } + + pub fn from_bytes(bytes: &'a [u8]) -> CodedInputStream<'a> { + CodedInputStream { source: BufReadIter::from_byte_slice(bytes) } + } + + #[cfg(feature = "bytes")] + pub fn from_carllerche_bytes(bytes: &'a Bytes) -> CodedInputStream<'a> { + CodedInputStream { source: BufReadIter::from_bytes(bytes) } + } + + pub fn pos(&self) -> u64 { + self.source.pos() + } + + pub fn bytes_until_limit(&self) -> u64 { + self.source.bytes_until_limit() + } + + pub fn read(&mut self, buf: &mut [u8]) -> ProtobufResult<()> { + self.source.read_exact(buf)?; + Ok(()) + } + + #[cfg(feature = "bytes")] + fn read_raw_callerche_bytes(&mut self, count: usize) -> ProtobufResult { + let r = self.source.read_exact_bytes(count)?; + Ok(r) + } + + #[inline(always)] + pub fn read_raw_byte(&mut self) -> ProtobufResult { + self.source.read_byte() + } + + pub fn push_limit(&mut self, limit: u64) -> ProtobufResult { + self.source.push_limit(limit) + } + + pub fn pop_limit(&mut self, old_limit: u64) { + self.source.pop_limit(old_limit); + } + + #[inline(always)] + pub fn eof(&mut self) -> ProtobufResult { + Ok(self.source.eof()?) + } + + pub fn check_eof(&mut self) -> ProtobufResult<()> { + let eof = self.eof()?; + if !eof { + return Err(ProtobufError::WireError(WireError::UnexpectedEof)); + } + Ok(()) + } + + fn read_raw_varint64_slow(&mut self) -> ProtobufResult { + let mut r: u64 = 0; + let mut i = 0; + loop { + if i == 10 { + return Err(ProtobufError::WireError(WireError::IncorrectVarint)); + } + let b = self.read_raw_byte()?; + // TODO: may overflow if i == 9 + r = r | (((b & 0x7f) as u64) << (i * 7)); + i += 1; + if b < 0x80 { + return Ok(r); + } + } + } + + #[inline(always)] + pub fn read_raw_varint64(&mut self) -> ProtobufResult { + 'slow: loop { + let ret; + let consume; + + loop { + let rem = self.source.remaining_in_buf(); + + if rem.len() >= 1 { + // most varints are in practice fit in 1 byte + if rem[0] < 0x80 { + ret = rem[0] as u64; + consume = 1; + } else { + // handle case of two bytes too + if rem.len() >= 2 && rem[1] < 0x80 { + ret = (rem[0] & 0x7f) as u64 | (rem[1] as u64) << 7; + consume = 2; + } else if rem.len() >= 10 { + // Read from array when buf at at least 10 bytes, + // max len for varint. + let mut r: u64 = 0; + let mut i: usize = 0; + { + let rem = rem; + loop { + if i == 10 { + return Err( + ProtobufError::WireError(WireError::IncorrectVarint), + ); + } + + let b = if true { + // skip range check + unsafe { *rem.get_unchecked(i) } + } else { + rem[i] + }; + + // TODO: may overflow if i == 9 + r = r | (((b & 0x7f) as u64) << (i * 7)); + i += 1; + if b < 0x80 { + break; + } + } + } + consume = i; + ret = r; + } else { + break 'slow; + } + } + } else { + break 'slow; + } + break; + } + + self.source.consume(consume); + return Ok(ret); + } + + self.read_raw_varint64_slow() + } + + #[inline(always)] + pub fn read_raw_varint32(&mut self) -> ProtobufResult { + self.read_raw_varint64().map(|v| v as u32) + } + + + pub fn read_raw_little_endian32(&mut self) -> ProtobufResult { + let mut r = 0u32; + let bytes: &mut [u8] = unsafe { + let p: *mut u8 = mem::transmute(&mut r); + slice::from_raw_parts_mut(p, mem::size_of::()) + }; + self.read(bytes)?; + Ok(r.to_le()) + } + + pub fn read_raw_little_endian64(&mut self) -> ProtobufResult { + let mut r = 0u64; + let bytes: &mut [u8] = unsafe { + let p: *mut u8 = mem::transmute(&mut r); + slice::from_raw_parts_mut(p, mem::size_of::()) + }; + self.read(bytes)?; + Ok(r.to_le()) + } + + #[inline] + pub fn read_tag(&mut self) -> ProtobufResult { + let v = self.read_raw_varint32()?; + match wire_format::Tag::new(v) { + Some(tag) => Ok(tag), + None => Err(ProtobufError::WireError(WireError::IncorrectTag(v))), + } + } + + // Read tag, return it is pair (field number, wire type) + #[inline] + pub fn read_tag_unpack(&mut self) -> ProtobufResult<(u32, wire_format::WireType)> { + self.read_tag().map(|t| t.unpack()) + } + + pub fn read_double(&mut self) -> ProtobufResult { + let bits = self.read_raw_little_endian64()?; + unsafe { Ok(mem::transmute::(bits)) } + } + + pub fn read_float(&mut self) -> ProtobufResult { + let bits = self.read_raw_little_endian32()?; + unsafe { Ok(mem::transmute::(bits)) } + } + + pub fn read_int64(&mut self) -> ProtobufResult { + self.read_raw_varint64().map(|v| v as i64) + } + + pub fn read_int32(&mut self) -> ProtobufResult { + self.read_raw_varint32().map(|v| v as i32) + } + + pub fn read_uint64(&mut self) -> ProtobufResult { + self.read_raw_varint64() + } + + pub fn read_uint32(&mut self) -> ProtobufResult { + self.read_raw_varint32() + } + + pub fn read_sint64(&mut self) -> ProtobufResult { + self.read_uint64().map(decode_zig_zag_64) + } + + pub fn read_sint32(&mut self) -> ProtobufResult { + self.read_uint32().map(decode_zig_zag_32) + } + + pub fn read_fixed64(&mut self) -> ProtobufResult { + self.read_raw_little_endian64() + } + + pub fn read_fixed32(&mut self) -> ProtobufResult { + self.read_raw_little_endian32() + } + + pub fn read_sfixed64(&mut self) -> ProtobufResult { + self.read_raw_little_endian64().map(|v| v as i64) + } + + pub fn read_sfixed32(&mut self) -> ProtobufResult { + self.read_raw_little_endian32().map(|v| v as i32) + } + + pub fn read_bool(&mut self) -> ProtobufResult { + self.read_raw_varint32().map(|v| v != 0) + } + + pub fn read_enum(&mut self) -> ProtobufResult { + let i = self.read_int32()?; + match ProtobufEnum::from_i32(i) { + Some(e) => Ok(e), + None => Err(ProtobufError::WireError(WireError::InvalidEnumValue(i))), + } + } + + pub fn read_repeated_packed_double_into( + &mut self, + target: &mut Vec, + ) -> ProtobufResult<()> { + let len = self.read_raw_varint64()?; + + target.reserve((len / 4) as usize); + + let old_limit = self.push_limit(len)?; + while !self.eof()? { + target.push(self.read_double()?); + } + self.pop_limit(old_limit); + Ok(()) + } + + pub fn read_repeated_packed_float_into(&mut self, target: &mut Vec) -> ProtobufResult<()> { + let len = self.read_raw_varint64()?; + + target.reserve((len / 4) as usize); + + let old_limit = self.push_limit(len)?; + while !self.eof()? { + target.push(self.read_float()?); + } + self.pop_limit(old_limit); + Ok(()) + } + + pub fn read_repeated_packed_int64_into(&mut self, target: &mut Vec) -> ProtobufResult<()> { + let len = self.read_raw_varint64()?; + let old_limit = self.push_limit(len as u64)?; + while !self.eof()? { + target.push(self.read_int64()?); + } + self.pop_limit(old_limit); + Ok(()) + } + + pub fn read_repeated_packed_int32_into(&mut self, target: &mut Vec) -> ProtobufResult<()> { + let len = self.read_raw_varint64()?; + let old_limit = self.push_limit(len)?; + while !self.eof()? { + target.push(self.read_int32()?); + } + self.pop_limit(old_limit); + Ok(()) + } + + pub fn read_repeated_packed_uint64_into( + &mut self, + target: &mut Vec, + ) -> ProtobufResult<()> { + let len = self.read_raw_varint64()?; + let old_limit = self.push_limit(len)?; + while !self.eof()? { + target.push(self.read_uint64()?); + } + self.pop_limit(old_limit); + Ok(()) + } + + pub fn read_repeated_packed_uint32_into( + &mut self, + target: &mut Vec, + ) -> ProtobufResult<()> { + let len = self.read_raw_varint64()?; + let old_limit = self.push_limit(len)?; + while !self.eof()? { + target.push(self.read_uint32()?); + } + self.pop_limit(old_limit); + Ok(()) + } + + pub fn read_repeated_packed_sint64_into( + &mut self, + target: &mut Vec, + ) -> ProtobufResult<()> { + let len = self.read_raw_varint64()?; + let old_limit = self.push_limit(len)?; + while !self.eof()? { + target.push(self.read_sint64()?); + } + self.pop_limit(old_limit); + Ok(()) + } + + pub fn read_repeated_packed_sint32_into( + &mut self, + target: &mut Vec, + ) -> ProtobufResult<()> { + let len = self.read_raw_varint64()?; + let old_limit = self.push_limit(len)?; + while !self.eof()? { + target.push(self.read_sint32()?); + } + self.pop_limit(old_limit); + Ok(()) + } + + pub fn read_repeated_packed_fixed64_into( + &mut self, + target: &mut Vec, + ) -> ProtobufResult<()> { + let len = self.read_raw_varint64()?; + + target.reserve((len / 8) as usize); + + let old_limit = self.push_limit(len)?; + while !self.eof()? { + target.push(self.read_fixed64()?); + } + self.pop_limit(old_limit); + Ok(()) + } + + pub fn read_repeated_packed_fixed32_into( + &mut self, + target: &mut Vec, + ) -> ProtobufResult<()> { + let len = self.read_raw_varint64()?; + + target.reserve((len / 4) as usize); + + let old_limit = self.push_limit(len)?; + while !self.eof()? { + target.push(self.read_fixed32()?); + } + self.pop_limit(old_limit); + Ok(()) + } + + pub fn read_repeated_packed_sfixed64_into( + &mut self, + target: &mut Vec, + ) -> ProtobufResult<()> { + let len = self.read_raw_varint64()?; + + target.reserve((len / 8) as usize); + + let old_limit = self.push_limit(len)?; + while !self.eof()? { + target.push(self.read_sfixed64()?); + } + self.pop_limit(old_limit); + Ok(()) + } + + pub fn read_repeated_packed_sfixed32_into( + &mut self, + target: &mut Vec, + ) -> ProtobufResult<()> { + let len = self.read_raw_varint64()?; + + target.reserve((len / 4) as usize); + + let old_limit = self.push_limit(len)?; + while !self.eof()? { + target.push(self.read_sfixed32()?); + } + self.pop_limit(old_limit); + Ok(()) + } + + pub fn read_repeated_packed_bool_into(&mut self, target: &mut Vec) -> ProtobufResult<()> { + let len = self.read_raw_varint64()?; + + // regular bool value is 1-byte size + target.reserve(len as usize); + + let old_limit = self.push_limit(len)?; + while !self.eof()? { + target.push(self.read_bool()?); + } + self.pop_limit(old_limit); + Ok(()) + } + + pub fn read_repeated_packed_enum_into( + &mut self, + target: &mut Vec, + ) -> ProtobufResult<()> { + let len = self.read_raw_varint64()?; + let old_limit = self.push_limit(len)?; + while !self.eof()? { + target.push(self.read_enum()?); + } + self.pop_limit(old_limit); + Ok(()) + } + + pub fn read_unknown( + &mut self, + wire_type: wire_format::WireType, + ) -> ProtobufResult { + match wire_type { + wire_format::WireTypeVarint => { + self.read_raw_varint64().map(|v| UnknownValue::Varint(v)) + } + wire_format::WireTypeFixed64 => self.read_fixed64().map(|v| UnknownValue::Fixed64(v)), + wire_format::WireTypeFixed32 => self.read_fixed32().map(|v| UnknownValue::Fixed32(v)), + wire_format::WireTypeLengthDelimited => { + let len = self.read_raw_varint32()?; + self.read_raw_bytes(len) + .map(|v| UnknownValue::LengthDelimited(v)) + } + _ => Err(ProtobufError::WireError( + WireError::UnexpectedWireType(wire_type), + )), + } + } + + pub fn skip_field(&mut self, wire_type: wire_format::WireType) -> ProtobufResult<()> { + self.read_unknown(wire_type).map(|_| ()) + } + + /// Read raw bytes into the supplied vector. The vector will be resized as needed and + /// overwritten. + pub fn read_raw_bytes_into(&mut self, count: u32, target: &mut Vec) -> ProtobufResult<()> { + unsafe { + target.set_len(0); + } + target.reserve(count as usize); + unsafe { + target.set_len(count as usize); + } + self.read(target)?; + Ok(()) + } + + /// Read exact number of bytes + pub fn read_raw_bytes(&mut self, count: u32) -> ProtobufResult> { + let mut r = Vec::new(); + self.read_raw_bytes_into(count, &mut r)?; + Ok(r) + } + + pub fn skip_raw_bytes(&mut self, count: u32) -> ProtobufResult<()> { + // TODO: make it more efficient + self.read_raw_bytes(count).map(|_| ()) + } + + pub fn read_bytes(&mut self) -> ProtobufResult> { + let mut r = Vec::new(); + self.read_bytes_into(&mut r)?; + Ok(r) + } + + #[cfg(feature = "bytes")] + pub fn read_carllerche_bytes(&mut self) -> ProtobufResult { + let len = self.read_raw_varint32()?; + self.read_raw_callerche_bytes(len as usize) + } + + #[cfg(feature = "bytes")] + pub fn read_carllerche_chars(&mut self) -> ProtobufResult { + let bytes = self.read_carllerche_bytes()?; + Ok(Chars::from_bytes(bytes)?) + } + + pub fn read_bytes_into(&mut self, target: &mut Vec) -> ProtobufResult<()> { + let len = self.read_raw_varint32()?; + self.read_raw_bytes_into(len, target)?; + Ok(()) + } + + pub fn read_string(&mut self) -> ProtobufResult { + let mut r = String::new(); + self.read_string_into(&mut r)?; + Ok(r) + } + + pub fn read_string_into(&mut self, target: &mut String) -> ProtobufResult<()> { + // assert string is empty, otherwize UTF-8 validation is too expensive + assert!(target.is_empty()); + // take target's buffer + let mut vec = mem::replace(target, String::new()).into_bytes(); + self.read_bytes_into(&mut vec)?; + + let s = match String::from_utf8(vec) { + Ok(t) => t, + Err(_) => return Err(ProtobufError::WireError(WireError::Utf8Error)), + }; + mem::replace(target, s); + Ok(()) + } + + pub fn merge_message(&mut self, message: &mut M) -> ProtobufResult<()> { + let len = self.read_raw_varint64()?; + let old_limit = self.push_limit(len)?; + message.merge_from(self)?; + self.pop_limit(old_limit); + Ok(()) + } + + pub fn read_message(&mut self) -> ProtobufResult { + let mut r: M = MessageStatic::new(); + self.merge_message(&mut r)?; + r.check_initialized()?; + Ok(r) + } +} + +pub trait WithCodedOutputStream { + fn with_coded_output_stream(self, cb: F) -> ProtobufResult + where + F : FnOnce(&mut CodedOutputStream) -> ProtobufResult; +} + +impl<'a> WithCodedOutputStream for &'a mut (Write + 'a) { + fn with_coded_output_stream(self, cb: F) -> ProtobufResult + where + F : FnOnce(&mut CodedOutputStream) -> ProtobufResult, + { + let mut os = CodedOutputStream::new(self); + let r = cb(&mut os)?; + os.flush()?; + Ok(r) + } +} + +impl<'a> WithCodedOutputStream for &'a mut Vec { + fn with_coded_output_stream(mut self, cb: F) -> ProtobufResult + where + F : FnOnce(&mut CodedOutputStream) -> ProtobufResult, + { + let mut os = CodedOutputStream::vec(&mut self); + let r = cb(&mut os)?; + os.flush()?; + Ok(r) + } +} + +pub fn with_coded_output_stream_to_bytes(cb: F) -> ProtobufResult> +where + F : FnOnce(&mut CodedOutputStream) -> ProtobufResult<()>, +{ + let mut v = Vec::new(); + v.with_coded_output_stream(cb)?; + Ok(v) +} + +pub trait WithCodedInputStream { + fn with_coded_input_stream(self, cb: F) -> ProtobufResult + where + F : FnOnce(&mut CodedInputStream) -> ProtobufResult; +} + +impl<'a> WithCodedInputStream for &'a mut (Read + 'a) { + fn with_coded_input_stream(self, cb: F) -> ProtobufResult + where + F : FnOnce(&mut CodedInputStream) -> ProtobufResult, + { + let mut is = CodedInputStream::new(self); + let r = cb(&mut is)?; + is.check_eof()?; + Ok(r) + } +} + +impl<'a> WithCodedInputStream for &'a mut (BufRead + 'a) { + fn with_coded_input_stream(self, cb: F) -> ProtobufResult + where + F : FnOnce(&mut CodedInputStream) -> ProtobufResult, + { + let mut is = CodedInputStream::from_buffered_reader(self); + let r = cb(&mut is)?; + is.check_eof()?; + Ok(r) + } +} + +impl<'a> WithCodedInputStream for &'a [u8] { + fn with_coded_input_stream(self, cb: F) -> ProtobufResult + where + F : FnOnce(&mut CodedInputStream) -> ProtobufResult, + { + let mut is = CodedInputStream::from_bytes(self); + let r = cb(&mut is)?; + is.check_eof()?; + Ok(r) + } +} + +#[cfg(feature = "bytes")] +impl<'a> WithCodedInputStream for &'a Bytes { + fn with_coded_input_stream(self, cb: F) -> ProtobufResult + where + F : FnOnce(&mut CodedInputStream) -> ProtobufResult, + { + let mut is = CodedInputStream::from_carllerche_bytes(self); + let r = cb(&mut is)?; + is.check_eof()?; + Ok(r) + } +} + + +enum OutputTarget<'a> { + Write(&'a mut Write, Vec), + Vec(&'a mut Vec), + Bytes, +} + + +pub struct CodedOutputStream<'a> { + target: OutputTarget<'a>, + // alias to buf from target + buffer: &'a mut [u8], + // within buffer + position: usize, +} + +impl<'a> CodedOutputStream<'a> { + pub fn new(writer: &'a mut Write) -> CodedOutputStream<'a> { + let buffer_len = OUTPUT_STREAM_BUFFER_SIZE; + + let mut buffer_storage = Vec::with_capacity(buffer_len); + unsafe { + buffer_storage.set_len(buffer_len); + } + + let buffer = unsafe { remove_lifetime_mut(&mut buffer_storage as &mut [u8]) }; + + CodedOutputStream { + target: OutputTarget::Write(writer, buffer_storage), + buffer: buffer, + position: 0, + } + } + + /// `CodedOutputStream` which writes directly to bytes. + /// + /// Attempt to write more than bytes capacity results in error. + pub fn bytes(bytes: &'a mut [u8]) -> CodedOutputStream<'a> { + CodedOutputStream { + target: OutputTarget::Bytes, + buffer: bytes, + position: 0, + } + } + + /// `CodedOutputStream` which writes directly to `Vec`. + /// + /// Caller should call `flush` at the end to guarantee vec contains + /// all written data. + pub fn vec(vec: &'a mut Vec) -> CodedOutputStream<'a> { + CodedOutputStream { + target: OutputTarget::Vec(vec), + buffer: &mut [], + position: 0, + } + } + + pub fn check_eof(&self) { + match self.target { + OutputTarget::Bytes => { + assert_eq!(self.buffer.len() as u64, self.position as u64); + } + OutputTarget::Write(..) | + OutputTarget::Vec(..) => { + panic!("must not be called with Writer or Vec"); + } + } + } + + fn refresh_buffer(&mut self) -> ProtobufResult<()> { + match self.target { + OutputTarget::Write(ref mut write, _) => { + write.write_all(&self.buffer[0..self.position as usize])?; + self.position = 0; + } + OutputTarget::Vec(ref mut vec) => unsafe { + let vec_len = vec.len(); + assert!(vec_len + self.position <= vec.capacity()); + vec.set_len(vec_len + self.position); + vec.reserve(1); + self.buffer = remove_lifetime_mut(remaining_capacity_as_slice_mut(vec)); + self.position = 0; + }, + OutputTarget::Bytes => { + panic!("refresh_buffer must not be called on CodedOutputStream create from slice"); + } + } + Ok(()) + } + + pub fn flush(&mut self) -> ProtobufResult<()> { + match self.target { + OutputTarget::Bytes => Ok(()), + OutputTarget::Write(..) | + OutputTarget::Vec(..) => { + // TODO: must not reserve additional in Vec + self.refresh_buffer() + } + } + } + + pub fn write_raw_byte(&mut self, byte: u8) -> ProtobufResult<()> { + if self.position as usize == self.buffer.len() { + self.refresh_buffer()?; + } + self.buffer[self.position as usize] = byte; + self.position += 1; + Ok(()) + } + + pub fn write_raw_bytes(&mut self, bytes: &[u8]) -> ProtobufResult<()> { + if bytes.len() <= self.buffer.len() - self.position { + let bottom = self.position as usize; + let top = bottom + (bytes.len() as usize); + self.buffer[bottom..top].copy_from_slice(bytes); + self.position += bytes.len(); + return Ok(()); + } + + self.refresh_buffer()?; + + assert!(self.position == 0); + + if self.position + bytes.len() < self.buffer.len() { + &mut self.buffer[self.position..self.position + bytes.len()].copy_from_slice(bytes); + self.position += bytes.len(); + return Ok(()); + } + + match self.target { + OutputTarget::Bytes => { + unreachable!(); + } + OutputTarget::Write(ref mut write, _) => { + write.write_all(bytes)?; + } + OutputTarget::Vec(ref mut vec) => { + vec.extend(bytes); + unsafe { + self.buffer = remove_lifetime_mut(remaining_capacity_as_slice_mut(vec)); + } + } + } + Ok(()) + } + + pub fn write_tag( + &mut self, + field_number: u32, + wire_type: wire_format::WireType, + ) -> ProtobufResult<()> { + self.write_raw_varint32(wire_format::Tag::make(field_number, wire_type).value()) + } + + pub fn write_raw_varint32(&mut self, value: u32) -> ProtobufResult<()> { + if self.buffer.len() - self.position >= 5 { + // fast path + let len = varint::encode_varint32(value, &mut self.buffer[self.position..]); + self.position += len; + Ok(()) + } else { + // slow path + let buf = &mut [0u8; 5]; + let len = varint::encode_varint32(value, buf); + self.write_raw_bytes(&buf[..len]) + } + } + + pub fn write_raw_varint64(&mut self, value: u64) -> ProtobufResult<()> { + if self.buffer.len() - self.position >= 10 { + // fast path + let len = varint::encode_varint64(value, &mut self.buffer[self.position..]); + self.position += len; + Ok(()) + } else { + // slow path + let buf = &mut [0u8; 10]; + let len = varint::encode_varint64(value, buf); + self.write_raw_bytes(&buf[..len]) + } + } + + pub fn write_raw_little_endian32(&mut self, value: u32) -> ProtobufResult<()> { + let bytes = unsafe { mem::transmute::<_, [u8; 4]>(value.to_le()) }; + self.write_raw_bytes(&bytes) + } + + pub fn write_raw_little_endian64(&mut self, value: u64) -> ProtobufResult<()> { + let bytes = unsafe { mem::transmute::<_, [u8; 8]>(value.to_le()) }; + self.write_raw_bytes(&bytes) + } + + pub fn write_float_no_tag(&mut self, value: f32) -> ProtobufResult<()> { + let bits = unsafe { mem::transmute::(value) }; + self.write_raw_little_endian32(bits) + } + + pub fn write_double_no_tag(&mut self, value: f64) -> ProtobufResult<()> { + let bits = unsafe { mem::transmute::(value) }; + self.write_raw_little_endian64(bits) + } + + pub fn write_float(&mut self, field_number: u32, value: f32) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeFixed32)?; + self.write_float_no_tag(value)?; + Ok(()) + } + + pub fn write_double(&mut self, field_number: u32, value: f64) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeFixed64)?; + self.write_double_no_tag(value)?; + Ok(()) + } + + pub fn write_uint64_no_tag(&mut self, value: u64) -> ProtobufResult<()> { + self.write_raw_varint64(value) + } + + pub fn write_uint32_no_tag(&mut self, value: u32) -> ProtobufResult<()> { + self.write_raw_varint32(value) + } + + pub fn write_int64_no_tag(&mut self, value: i64) -> ProtobufResult<()> { + self.write_raw_varint64(value as u64) + } + + pub fn write_int32_no_tag(&mut self, value: i32) -> ProtobufResult<()> { + self.write_raw_varint64(value as u64) + } + + pub fn write_sint64_no_tag(&mut self, value: i64) -> ProtobufResult<()> { + self.write_uint64_no_tag(encode_zig_zag_64(value)) + } + + pub fn write_sint32_no_tag(&mut self, value: i32) -> ProtobufResult<()> { + self.write_uint32_no_tag(encode_zig_zag_32(value)) + } + + pub fn write_fixed64_no_tag(&mut self, value: u64) -> ProtobufResult<()> { + self.write_raw_little_endian64(value) + } + + pub fn write_fixed32_no_tag(&mut self, value: u32) -> ProtobufResult<()> { + self.write_raw_little_endian32(value) + } + + pub fn write_sfixed64_no_tag(&mut self, value: i64) -> ProtobufResult<()> { + self.write_raw_little_endian64(value as u64) + } + + pub fn write_sfixed32_no_tag(&mut self, value: i32) -> ProtobufResult<()> { + self.write_raw_little_endian32(value as u32) + } + + pub fn write_bool_no_tag(&mut self, value: bool) -> ProtobufResult<()> { + self.write_raw_varint32(if value { 1 } else { 0 }) + } + + pub fn write_enum_no_tag(&mut self, value: i32) -> ProtobufResult<()> { + self.write_int32_no_tag(value) + } + + pub fn write_enum_obj_no_tag(&mut self, value: E) -> ProtobufResult<()> + where + E : ProtobufEnum, + { + self.write_enum_no_tag(value.value()) + } + + pub fn write_unknown_no_tag(&mut self, unknown: UnknownValueRef) -> ProtobufResult<()> { + match unknown { + UnknownValueRef::Fixed64(fixed64) => self.write_raw_little_endian64(fixed64), + UnknownValueRef::Fixed32(fixed32) => self.write_raw_little_endian32(fixed32), + UnknownValueRef::Varint(varint) => self.write_raw_varint64(varint), + UnknownValueRef::LengthDelimited(bytes) => self.write_bytes_no_tag(bytes), + } + } + + pub fn write_uint64(&mut self, field_number: u32, value: u64) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeVarint)?; + self.write_uint64_no_tag(value)?; + Ok(()) + } + + pub fn write_uint32(&mut self, field_number: u32, value: u32) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeVarint)?; + self.write_uint32_no_tag(value)?; + Ok(()) + } + + pub fn write_int64(&mut self, field_number: u32, value: i64) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeVarint)?; + self.write_int64_no_tag(value)?; + Ok(()) + } + + pub fn write_int32(&mut self, field_number: u32, value: i32) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeVarint)?; + self.write_int32_no_tag(value)?; + Ok(()) + } + + pub fn write_sint64(&mut self, field_number: u32, value: i64) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeVarint)?; + self.write_sint64_no_tag(value)?; + Ok(()) + } + + pub fn write_sint32(&mut self, field_number: u32, value: i32) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeVarint)?; + self.write_sint32_no_tag(value)?; + Ok(()) + } + + pub fn write_fixed64(&mut self, field_number: u32, value: u64) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeFixed64)?; + self.write_fixed64_no_tag(value)?; + Ok(()) + } + + pub fn write_fixed32(&mut self, field_number: u32, value: u32) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeFixed32)?; + self.write_fixed32_no_tag(value)?; + Ok(()) + } + + pub fn write_sfixed64(&mut self, field_number: u32, value: i64) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeFixed64)?; + self.write_sfixed64_no_tag(value)?; + Ok(()) + } + + pub fn write_sfixed32(&mut self, field_number: u32, value: i32) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeFixed32)?; + self.write_sfixed32_no_tag(value)?; + Ok(()) + } + + pub fn write_bool(&mut self, field_number: u32, value: bool) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeVarint)?; + self.write_bool_no_tag(value)?; + Ok(()) + } + + pub fn write_enum(&mut self, field_number: u32, value: i32) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeVarint)?; + self.write_enum_no_tag(value)?; + Ok(()) + } + + pub fn write_enum_obj(&mut self, field_number: u32, value: E) -> ProtobufResult<()> + where + E : ProtobufEnum, + { + self.write_enum(field_number, value.value()) + } + + pub fn write_unknown( + &mut self, + field_number: u32, + value: UnknownValueRef, + ) -> ProtobufResult<()> { + self.write_tag(field_number, value.wire_type())?; + self.write_unknown_no_tag(value)?; + Ok(()) + } + + pub fn write_unknown_fields(&mut self, fields: &UnknownFields) -> ProtobufResult<()> { + for (number, values) in fields { + for value in values { + self.write_unknown(number, value)?; + } + } + Ok(()) + } + + pub fn write_bytes_no_tag(&mut self, bytes: &[u8]) -> ProtobufResult<()> { + self.write_raw_varint32(bytes.len() as u32)?; + self.write_raw_bytes(bytes)?; + Ok(()) + } + + pub fn write_string_no_tag(&mut self, s: &str) -> ProtobufResult<()> { + self.write_bytes_no_tag(s.as_bytes()) + } + + pub fn write_message_no_tag(&mut self, msg: &M) -> ProtobufResult<()> { + msg.write_length_delimited_to(self) + } + + pub fn write_bytes(&mut self, field_number: u32, bytes: &[u8]) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeLengthDelimited)?; + self.write_bytes_no_tag(bytes)?; + Ok(()) + } + + pub fn write_string(&mut self, field_number: u32, s: &str) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeLengthDelimited)?; + self.write_string_no_tag(s)?; + Ok(()) + } + + pub fn write_message(&mut self, field_number: u32, msg: &M) -> ProtobufResult<()> { + self.write_tag(field_number, wire_format::WireTypeLengthDelimited)?; + self.write_message_no_tag(msg)?; + Ok(()) + } +} + + +#[cfg(test)] +mod test { + + use std::io; + use std::io::BufRead; + use std::io::Write; + use std::iter::repeat; + use std::fmt::Debug; + + use hex::encode_hex; + use hex::decode_hex; + use error::ProtobufResult; + use error::ProtobufError; + + use super::wire_format; + use super::CodedInputStream; + use super::CodedOutputStream; + + fn test_read_partial(hex: &str, mut callback: F) + where + F : FnMut(&mut CodedInputStream), + { + let d = decode_hex(hex); + let mut reader = io::Cursor::new(d); + let mut is = CodedInputStream::from_buffered_reader(&mut reader as &mut BufRead); + assert_eq!(0, is.pos()); + callback(&mut is); + } + + fn test_read(hex: &str, mut callback: F) + where + F : FnMut(&mut CodedInputStream), + { + let len = decode_hex(hex).len(); + test_read_partial(hex, |reader| { + callback(reader); + assert!(reader.eof().expect("eof")); + assert_eq!(len as u64, reader.pos()); + }); + } + + fn test_read_v(hex: &str, v: V, mut callback: F) + where + F : FnMut(&mut CodedInputStream) -> ProtobufResult, + V : PartialEq + Debug, + { + test_read(hex, |reader| { + assert_eq!(v, callback(reader).unwrap()); + }); + } + + #[test] + fn test_input_stream_read_raw_byte() { + test_read("17", |is| { + assert_eq!(23, is.read_raw_byte().unwrap()); + }); + } + + #[test] + fn test_input_stream_read_raw_varint() { + test_read_v("07", 7, |reader| reader.read_raw_varint32()); + test_read_v("07", 7, |reader| reader.read_raw_varint64()); + + test_read_v("96 01", 150, |reader| reader.read_raw_varint32()); + test_read_v("96 01", 150, |reader| reader.read_raw_varint64()); + + test_read_v( + "ff ff ff ff ff ff ff ff ff 01", + 0xffffffffffffffff, + |reader| reader.read_raw_varint64(), + ); + + test_read_v("ff ff ff ff 0f", 0xffffffff, |reader| { + reader.read_raw_varint32() + }); + test_read_v("ff ff ff ff 0f", 0xffffffff, |reader| { + reader.read_raw_varint64() + }); + } + + #[test] + fn test_input_stream_read_raw_vaint_malformed() { + // varint cannot have length > 10 + test_read_partial("ff ff ff ff ff ff ff ff ff ff 01", |reader| { + let result = reader.read_raw_varint64(); + match result { + // TODO: make an enum variant + Err(ProtobufError::WireError(..)) => (), + _ => panic!(), + } + }); + test_read_partial("ff ff ff ff ff ff ff ff ff ff 01", |reader| { + let result = reader.read_raw_varint32(); + match result { + // TODO: make an enum variant + Err(ProtobufError::WireError(..)) => (), + _ => panic!(), + } + }); + } + + #[test] + fn test_input_stream_read_raw_varint_unexpected_eof() { + test_read_partial("96 97", |reader| { + let result = reader.read_raw_varint32(); + match result { + Err(ProtobufError::WireError(..)) => (), + _ => panic!(), + } + }); + } + + #[test] + fn test_input_stream_read_raw_varint_pos() { + test_read_partial("95 01 98", |reader| { + assert_eq!(149, reader.read_raw_varint32().unwrap()); + assert_eq!(2, reader.pos()); + }); + } + + #[test] + fn test_input_stream_read_int32() { + test_read_v("02", 2, |reader| reader.read_int32()); + } + + #[test] + fn test_input_stream_read_float() { + test_read_v("95 73 13 61", 17e19, |is| is.read_float()); + } + + #[test] + fn test_input_stream_read_double() { + test_read_v("40 d5 ab 68 b3 07 3d 46", 23e29, |is| is.read_double()); + } + + #[test] + fn test_input_stream_skip_raw_bytes() { + test_read("", |reader| { reader.skip_raw_bytes(0).unwrap(); }); + test_read("aa bb", |reader| { reader.skip_raw_bytes(2).unwrap(); }); + test_read("aa bb cc dd ee ff", |reader| { + reader.skip_raw_bytes(6).unwrap(); + }); + } + + #[test] + fn test_input_stream_read_raw_bytes() { + test_read("", |reader| { + assert_eq!( + Vec::from(&b""[..]), + reader.read_raw_bytes(0).expect("read_raw_bytes") + ); + }) + } + + #[test] + fn test_input_stream_limits() { + test_read("aa bb cc", |is| { + let old_limit = is.push_limit(1).unwrap(); + assert_eq!(1, is.bytes_until_limit()); + let r1 = is.read_raw_bytes(1).unwrap(); + assert_eq!(&[0xaa as u8], &r1[..]); + is.pop_limit(old_limit); + let r2 = is.read_raw_bytes(2).unwrap(); + assert_eq!(&[0xbb as u8, 0xcc], &r2[..]); + }); + } + + fn test_write(expected: &str, mut gen: F) + where + F : FnMut(&mut CodedOutputStream) -> ProtobufResult<()>, + { + let expected_bytes = decode_hex(expected); + + // write to Write + { + let mut v = Vec::new(); + { + let mut os = CodedOutputStream::new(&mut v as &mut Write); + gen(&mut os).unwrap(); + os.flush().unwrap(); + } + assert_eq!(encode_hex(&expected_bytes), encode_hex(&v)); + } + + // write to &[u8] + { + let mut r = Vec::with_capacity(expected_bytes.len()); + r.resize(expected_bytes.len(), 0); + { + let mut os = CodedOutputStream::bytes(&mut r); + gen(&mut os).unwrap(); + os.check_eof(); + } + assert_eq!(encode_hex(&expected_bytes), encode_hex(&r)); + } + + // write to Vec + { + let mut r = Vec::new(); + r.extend(&[11, 22, 33, 44, 55, 66, 77]); + { + let mut os = CodedOutputStream::vec(&mut r); + gen(&mut os).unwrap(); + os.flush().unwrap(); + } + + r.drain(..7); + assert_eq!(encode_hex(&expected_bytes), encode_hex(&r)); + } + } + + #[test] + fn test_output_stream_write_raw_byte() { + test_write("a1", |os| os.write_raw_byte(0xa1)); + } + + #[test] + fn test_output_stream_write_tag() { + test_write("08", |os| os.write_tag(1, wire_format::WireTypeVarint)); + } + + #[test] + fn test_output_stream_write_raw_bytes() { + test_write("00 ab", |os| os.write_raw_bytes(&[0x00, 0xab])); + + let expected = repeat("01 02 03 04") + .take(2048) + .collect::>() + .join(" "); + test_write(&expected, |os| { + for _ in 0..2048 { + os.write_raw_bytes(&[0x01, 0x02, 0x03, 0x04])?; + } + + Ok(()) + }); + } + + #[test] + fn test_output_stream_write_raw_varint32() { + test_write("96 01", |os| os.write_raw_varint32(150)); + test_write("ff ff ff ff 0f", |os| os.write_raw_varint32(0xffffffff)); + } + + #[test] + fn test_output_stream_write_raw_varint64() { + test_write("96 01", |os| os.write_raw_varint64(150)); + test_write("ff ff ff ff ff ff ff ff ff 01", |os| { + os.write_raw_varint64(0xffffffffffffffff) + }); + } + + #[test] + fn test_output_stream_write_int32_no_tag() { + test_write("ff ff ff ff ff ff ff ff ff 01", |os| { + os.write_int32_no_tag(-1) + }); + } + + #[test] + fn test_output_stream_write_int64_no_tag() { + test_write("ff ff ff ff ff ff ff ff ff 01", |os| { + os.write_int64_no_tag(-1) + }); + } + + #[test] + fn test_output_stream_write_raw_little_endian32() { + test_write("f1 e2 d3 c4", |os| os.write_raw_little_endian32(0xc4d3e2f1)); + } + + #[test] + fn test_output_stream_write_float_no_tag() { + test_write("95 73 13 61", |os| os.write_float_no_tag(17e19)); + } + + #[test] + fn test_output_stream_write_double_no_tag() { + test_write( + "40 d5 ab 68 b3 07 3d 46", + |os| os.write_double_no_tag(23e29), + ); + } + + #[test] + fn test_output_stream_write_raw_little_endian64() { + test_write("f1 e2 d3 c4 b5 a6 07 f8", |os| { + os.write_raw_little_endian64(0xf807a6b5c4d3e2f1) + }); + } +} diff --git a/third_party/protobuf/src/strx.rs b/third_party/protobuf/src/strx.rs new file mode 100644 index 000000000..2c972dd48 --- /dev/null +++ b/third_party/protobuf/src/strx.rs @@ -0,0 +1,35 @@ +pub fn remove_to<'s>(s: &'s str, c: char) -> &'s str { + match s.rfind(c) { + Some(pos) => &s[(pos + 1)..], + None => s, + } +} + +pub fn remove_suffix<'s>(s: &'s str, suffix: &str) -> Option<&'s str> { + if !s.ends_with(suffix) { + None + } else { + Some(&s[..(s.len() - suffix.len())]) + } +} + +#[cfg(test)] +mod test { + + use super::remove_to; + use super::remove_suffix; + + #[test] + fn test_remove_to() { + assert_eq!("aaa", remove_to("aaa", '.')); + assert_eq!("bbb", remove_to("aaa.bbb", '.')); + assert_eq!("ccc", remove_to("aaa.bbb.ccc", '.')); + } + + #[test] + fn test_remove_suffix() { + assert_eq!(Some("bbb"), remove_suffix("bbbaaa", "aaa")); + assert_eq!(None, remove_suffix("aaa", "bbb")); + } + +} diff --git a/third_party/protobuf/src/text_format.rs b/third_party/protobuf/src/text_format.rs new file mode 100644 index 000000000..8b8af61fb --- /dev/null +++ b/third_party/protobuf/src/text_format.rs @@ -0,0 +1,291 @@ +use std; +use std::fmt; +use std::fmt::Write; +use std::string::String; +use std::string::ToString; +use std::vec::Vec; +use protocore::Message; +use reflect::ReflectFieldRef; +use reflect::ProtobufValueRef; + + +fn quote_bytes_to(bytes: &[u8], buf: &mut String) { + for &c in bytes { + match c { + b'\n' => buf.push_str(r"\n"), + b'\r' => buf.push_str(r"\r"), + b'\t' => buf.push_str(r"\t"), + b'"' => buf.push_str("\\\""), + b'\\' => buf.push_str(r"\\"), + b'\x20'...b'\x7e' => buf.push(c as char), + _ => { + buf.push('\\'); + buf.push((b'0' + (c >> 6)) as char); + buf.push((b'0' + ((c >> 3) & 7)) as char); + buf.push((b'0' + (c & 7)) as char); + } + } + } +} + +fn quote_escape_bytes_to(bytes: &[u8], buf: &mut String) { + buf.push('"'); + quote_bytes_to(bytes, buf); + buf.push('"'); +} + +pub fn quote_escape_bytes(bytes: &[u8]) -> String { + let mut r = String::new(); + quote_escape_bytes_to(bytes, &mut r); + r +} + +pub fn unescape_string(string: &str) -> Vec { + fn parse_if_digit(chars: &mut std::str::Chars) -> u8 { + let mut copy = chars.clone(); + let f = match copy.next() { + None => return 0, + Some(f) => f, + }; + let d = match f { + '0'...'9' => (f as u8 - b'0'), + _ => return 0, + }; + *chars = copy; + d + } + + fn parse_escape_rem(chars: &mut std::str::Chars) -> u8 { + let n = chars.next().unwrap(); + let d1 = match n { + 'a' => return b'\x07', + 'b' => return b'\x08', + 'f' => return b'\x0c', + 'n' => return b'\n', + 'r' => return b'\r', + 't' => return b'\t', + 'v' => return b'\x0b', + '"' => return b'"', + '0'...'9' => (n as u8 - b'0'), + c => return c as u8, // TODO: validate ASCII + }; + let d2 = parse_if_digit(chars); + let d3 = parse_if_digit(chars); + return (d1 * 64 + d2 * 8 + d3) as u8; + } + + let mut chars = string.chars(); + let mut r = Vec::new(); + + loop { + let f = match chars.next() { + None => return r, + Some(f) => f, + }; + + if f == '\\' { + r.push(parse_escape_rem(&mut chars)); + } else { + r.push(f as u8); // TODO: escape UTF-8 + } + } +} + +fn print_str_to(s: &str, buf: &mut String) { + // TODO: keep printable Unicode + quote_escape_bytes_to(s.as_bytes(), buf); +} + +fn do_indent(buf: &mut String, pretty: bool, indent: usize) { + if pretty && indent > 0 { + for _ in 0..indent { + buf.push_str(" "); + } + } +} + +fn print_start_field( + buf: &mut String, + pretty: bool, + indent: usize, + first: &mut bool, + field_name: &str, +) { + if !*first && !pretty { + buf.push_str(" "); + } + do_indent(buf, pretty, indent); + *first = false; + buf.push_str(field_name); +} + +fn print_end_field(buf: &mut String, pretty: bool) { + if pretty { + buf.push_str("\n"); + } +} + +fn print_field( + buf: &mut String, + pretty: bool, + indent: usize, + first: &mut bool, + field_name: &str, + value: ProtobufValueRef, +) { + print_start_field(buf, pretty, indent, first, field_name); + + match value { + ProtobufValueRef::Message(m) => { + buf.push_str(" {"); + if pretty { + buf.push_str("\n"); + } + print_to_internal(m, buf, pretty, indent + 1); + do_indent(buf, pretty, indent); + buf.push_str("}"); + } + ProtobufValueRef::Enum(e) => { + buf.push_str(": "); + buf.push_str(e.name()); + } + ProtobufValueRef::String(s) => { + buf.push_str(": "); + print_str_to(s, buf); + } + ProtobufValueRef::Bytes(b) => { + buf.push_str(": "); + quote_escape_bytes_to(b, buf); + } + ProtobufValueRef::I32(v) => { + write!(buf, ": {}", v).unwrap(); + } + ProtobufValueRef::I64(v) => { + write!(buf, ": {}", v).unwrap(); + } + ProtobufValueRef::U32(v) => { + write!(buf, ": {}", v).unwrap(); + } + ProtobufValueRef::U64(v) => { + write!(buf, ": {}", v).unwrap(); + } + ProtobufValueRef::Bool(v) => { + write!(buf, ": {}", v).unwrap(); + } + ProtobufValueRef::F32(v) => { + write!(buf, ": {}", v).unwrap(); + } + ProtobufValueRef::F64(v) => { + write!(buf, ": {}", v).unwrap(); + } + } + + print_end_field(buf, pretty); +} + +fn print_to_internal(m: &Message, buf: &mut String, pretty: bool, indent: usize) { + let d = m.descriptor(); + let mut first = true; + for f in d.fields() { + match f.get_reflect(m) { + ReflectFieldRef::Map(map) => { + for (k, v) in map { + print_start_field(buf, pretty, indent, &mut first, f.name()); + buf.push_str(" {"); + if pretty { + buf.push_str("\n"); + } + + let mut entry_first = true; + + print_field(buf, pretty, indent + 1, &mut entry_first, "key", k.as_ref()); + print_field( + buf, + pretty, + indent + 1, + &mut entry_first, + "value", + v.as_ref(), + ); + do_indent(buf, pretty, indent); + buf.push_str("}"); + print_end_field(buf, pretty); + } + } + ReflectFieldRef::Repeated(repeated) => { + // TODO: do not print zeros for v3 + for v in repeated { + print_field(buf, pretty, indent, &mut first, f.name(), v.as_ref()); + } + } + ReflectFieldRef::Optional(optional) => { + if let Some(v) = optional { + print_field(buf, pretty, indent, &mut first, f.name(), v); + } + } + ReflectFieldRef::RepeatedOld(..) => { + for i in 0..f.len_field(m) { + let v = f.get_rep_item(m, i); + print_field(buf, pretty, indent, &mut first, f.name(), v); + } + } + } + } + + // TODO: unknown fields +} + +pub fn print_to(m: &Message, buf: &mut String) { + print_to_internal(m, buf, false, 0) +} + +fn print_to_string_internal(m: &Message, pretty: bool) -> String { + let mut r = String::new(); + print_to_internal(m, &mut r, pretty, 0); + r.to_string() +} + +pub fn print_to_string(m: &Message) -> String { + print_to_string_internal(m, false) +} + +pub fn fmt(m: &Message, f: &mut fmt::Formatter) -> fmt::Result { + let pretty = f.alternate(); + f.write_str(&print_to_string_internal(m, pretty)) +} + +#[cfg(test)] +mod test { + + fn escape(data: &[u8]) -> String { + let mut s = String::with_capacity(data.len() * 4); + super::quote_bytes_to(data, &mut s); + s + } + + fn test_escape_unescape(text: &str, escaped: &str) { + assert_eq!(text.as_bytes(), &super::unescape_string(escaped)[..]); + assert_eq!(escaped, &escape(text.as_bytes())[..]); + } + + #[test] + fn test_print_to_bytes() { + assert_eq!("ab", escape(b"ab")); + assert_eq!("a\\\\023", escape(b"a\\023")); + assert_eq!("a\\r\\n\\t '\\\"\\\\", escape(b"a\r\n\t '\"\\")); + assert_eq!( + "\\344\\275\\240\\345\\245\\275", + escape("你好".as_bytes()) + ); + } + + #[test] + fn test_unescape_string() { + test_escape_unescape("", ""); + test_escape_unescape("aa", "aa"); + test_escape_unescape("\n", "\\n"); + test_escape_unescape("\r", "\\r"); + test_escape_unescape("\t", "\\t"); + test_escape_unescape("你好", "\\344\\275\\240\\345\\245\\275"); + } +} diff --git a/third_party/protobuf/src/types.rs b/third_party/protobuf/src/types.rs new file mode 100644 index 000000000..f3a0b9672 --- /dev/null +++ b/third_party/protobuf/src/types.rs @@ -0,0 +1,561 @@ +use std::marker; +use std::string::String; +use std::vec::Vec; + +#[cfg(feature = "bytes")] +use bytes::Bytes; +#[cfg(feature = "bytes")] +use chars::Chars; + +use stream::CodedInputStream; +use stream::CodedOutputStream; +use error::ProtobufResult; +use protocore::ProtobufEnum; +use protocore::Message; +use protocore::MessageStatic; +use wire_format::WireType; +use rt; +use reflect::ProtobufValue; +use unknown::UnknownValues; + +pub trait ProtobufType { + type Value: ProtobufValue + Clone + 'static; + + fn wire_type() -> WireType; + + fn read(is: &mut CodedInputStream) -> ProtobufResult; + + fn compute_size(value: &Self::Value) -> u32; + + /// Compute size adding length prefix if wire type is length delimited + /// (i. e. string, bytes, message) + fn compute_size_with_length_delimiter(value: &Self::Value) -> u32 { + let size = Self::compute_size(value); + if Self::wire_type() == WireType::WireTypeLengthDelimited { + rt::compute_raw_varint32_size(size) + size + } else { + size + } + } + + fn get_from_unknown(_unknown_values: &UnknownValues) -> Option { + unimplemented!() + } + + /// Get previously computed size + #[inline] + fn get_cached_size(value: &Self::Value) -> u32 { + Self::compute_size(value) + } + + /// Get previously cached size with length prefix + #[inline] + fn get_cached_size_with_length_delimiter(value: &Self::Value) -> u32 { + let size = Self::get_cached_size(value); + if Self::wire_type() == WireType::WireTypeLengthDelimited { + rt::compute_raw_varint32_size(size) + size + } else { + size + } + } + + fn write_with_cached_size( + field_number: u32, + value: &Self::Value, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()>; +} + +pub struct ProtobufTypeFloat; +pub struct ProtobufTypeDouble; +pub struct ProtobufTypeInt32; +pub struct ProtobufTypeInt64; +pub struct ProtobufTypeUint32; +pub struct ProtobufTypeUint64; +pub struct ProtobufTypeSint32; +pub struct ProtobufTypeSint64; +pub struct ProtobufTypeFixed32; +pub struct ProtobufTypeFixed64; +pub struct ProtobufTypeSfixed32; +pub struct ProtobufTypeSfixed64; +pub struct ProtobufTypeBool; +pub struct ProtobufTypeString; +pub struct ProtobufTypeBytes; +pub struct ProtobufTypeChars; + +#[cfg(feature = "bytes")] +pub struct ProtobufTypeCarllercheBytes; +#[cfg(feature = "bytes")] +pub struct ProtobufTypeCarllercheChars; + +pub struct ProtobufTypeEnum(marker::PhantomData); +pub struct ProtobufTypeMessage(marker::PhantomData); + +impl ProtobufType for ProtobufTypeFloat { + type Value = f32; + + fn wire_type() -> WireType { + WireType::WireTypeFixed32 + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_float() + } + + fn compute_size(_value: &f32) -> u32 { + 4 + } + + fn write_with_cached_size( + field_number: u32, + value: &f32, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_float(field_number, *value) + } +} + +impl ProtobufType for ProtobufTypeDouble { + type Value = f64; + + fn wire_type() -> WireType { + WireType::WireTypeFixed64 + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_double() + } + + fn compute_size(_value: &f64) -> u32 { + 8 + } + + fn write_with_cached_size( + field_number: u32, + value: &f64, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_double(field_number, *value) + } +} + +impl ProtobufType for ProtobufTypeInt32 { + type Value = i32; + + fn wire_type() -> WireType { + WireType::WireTypeVarint + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_int32() + } + + fn compute_size(value: &i32) -> u32 { + rt::compute_raw_varint32_size(*value as u32) + } + + fn write_with_cached_size( + field_number: u32, + value: &i32, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_int32(field_number, *value) + } +} + +impl ProtobufType for ProtobufTypeInt64 { + type Value = i64; + + fn wire_type() -> WireType { + WireType::WireTypeVarint + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_int64() + } + + fn compute_size(value: &i64) -> u32 { + rt::compute_raw_varint64_size(*value as u64) + } + + fn write_with_cached_size( + field_number: u32, + value: &i64, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_int64(field_number, *value) + } +} + +impl ProtobufType for ProtobufTypeUint32 { + type Value = u32; + + fn wire_type() -> WireType { + WireType::WireTypeVarint + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_uint32() + } + + fn compute_size(value: &u32) -> u32 { + rt::compute_raw_varint32_size(*value) + } + + fn write_with_cached_size( + field_number: u32, + value: &u32, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_uint32(field_number, *value) + } +} + +impl ProtobufType for ProtobufTypeUint64 { + type Value = u64; + + fn wire_type() -> WireType { + WireType::WireTypeVarint + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_uint64() + } + + fn compute_size(value: &u64) -> u32 { + rt::compute_raw_varint64_size(*value) + } + + fn write_with_cached_size( + field_number: u32, + value: &u64, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_uint64(field_number, *value) + } +} + +impl ProtobufType for ProtobufTypeSint32 { + type Value = i32; + + fn wire_type() -> WireType { + WireType::WireTypeVarint + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_sint32() + } + + fn compute_size(value: &i32) -> u32 { + rt::value_varint_zigzag_size_no_tag(*value) + } + + fn write_with_cached_size( + field_number: u32, + value: &i32, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_sint32(field_number, *value) + } +} + +impl ProtobufType for ProtobufTypeSint64 { + type Value = i64; + + fn wire_type() -> WireType { + WireType::WireTypeVarint + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_sint64() + } + + fn compute_size(value: &i64) -> u32 { + rt::value_varint_zigzag_size_no_tag(*value) + } + + fn write_with_cached_size( + field_number: u32, + value: &i64, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_sint64(field_number, *value) + } +} + +impl ProtobufType for ProtobufTypeFixed32 { + type Value = u32; + + fn wire_type() -> WireType { + WireType::WireTypeFixed32 + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_fixed32() + } + + fn compute_size(_value: &u32) -> u32 { + 4 + } + + fn write_with_cached_size( + field_number: u32, + value: &u32, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_fixed32(field_number, *value) + } +} + +impl ProtobufType for ProtobufTypeFixed64 { + type Value = u64; + + fn wire_type() -> WireType { + WireType::WireTypeFixed64 + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_fixed64() + } + + fn compute_size(_value: &u64) -> u32 { + 8 + } + + fn write_with_cached_size( + field_number: u32, + value: &u64, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_fixed64(field_number, *value) + } +} + +impl ProtobufType for ProtobufTypeSfixed32 { + type Value = i32; + + fn wire_type() -> WireType { + WireType::WireTypeFixed32 + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_sfixed32() + } + + fn compute_size(_value: &i32) -> u32 { + 4 + } + + fn write_with_cached_size( + field_number: u32, + value: &i32, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_sfixed32(field_number, *value) + } +} + +impl ProtobufType for ProtobufTypeSfixed64 { + type Value = i64; + + fn wire_type() -> WireType { + WireType::WireTypeFixed64 + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_sfixed64() + } + + fn compute_size(_value: &i64) -> u32 { + 8 + } + + fn write_with_cached_size( + field_number: u32, + value: &i64, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_sfixed64(field_number, *value) + } +} + +impl ProtobufType for ProtobufTypeBool { + type Value = bool; + + fn wire_type() -> WireType { + WireType::WireTypeVarint + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_bool() + } + + fn get_from_unknown(unknown: &UnknownValues) -> Option { + unknown.varint.iter().rev().next().map(|&v| v != 0) + } + + fn compute_size(_value: &bool) -> u32 { + 1 + } + + fn write_with_cached_size( + field_number: u32, + value: &bool, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_bool(field_number, *value) + } +} + +impl ProtobufType for ProtobufTypeString { + type Value = String; + + fn wire_type() -> WireType { + WireType::WireTypeLengthDelimited + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_string() + } + + fn compute_size(value: &String) -> u32 { + value.len() as u32 + } + + fn write_with_cached_size( + field_number: u32, + value: &String, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_string(field_number, &value) + } +} + +impl ProtobufType for ProtobufTypeBytes { + type Value = Vec; + + fn wire_type() -> WireType { + WireType::WireTypeLengthDelimited + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult> { + is.read_bytes() + } + + fn compute_size(value: &Vec) -> u32 { + value.len() as u32 + } + + fn write_with_cached_size( + field_number: u32, + value: &Vec, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_bytes(field_number, &value) + } +} + +#[cfg(feature = "bytes")] +impl ProtobufType for ProtobufTypeCarllercheBytes { + type Value = Bytes; + + fn wire_type() -> WireType { + ProtobufTypeBytes::wire_type() + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_carllerche_bytes() + } + + fn compute_size(value: &Bytes) -> u32 { + value.len() as u32 + } + + fn write_with_cached_size( + field_number: u32, + value: &Bytes, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_bytes(field_number, &value) + } +} + +#[cfg(feature = "bytes")] +impl ProtobufType for ProtobufTypeCarllercheChars { + type Value = Chars; + + fn wire_type() -> WireType { + ProtobufTypeBytes::wire_type() + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_carllerche_chars() + } + + fn compute_size(value: &Chars) -> u32 { + value.len() as u32 + } + + fn write_with_cached_size( + field_number: u32, + value: &Chars, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_string(field_number, &value) + } +} + +impl ProtobufType for ProtobufTypeEnum { + type Value = E; + + fn wire_type() -> WireType { + WireType::WireTypeVarint + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_enum() + } + + fn compute_size(value: &E) -> u32 { + rt::compute_raw_varint32_size(value.value() as u32) // TODO: wrap + } + + fn write_with_cached_size( + field_number: u32, + value: &E, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_enum_obj(field_number, *value) + } +} + +impl ProtobufType for ProtobufTypeMessage { + type Value = M; + + fn wire_type() -> WireType { + WireType::WireTypeLengthDelimited + } + + fn read(is: &mut CodedInputStream) -> ProtobufResult { + is.read_message() + } + + fn compute_size(value: &M) -> u32 { + value.compute_size() + } + + fn get_cached_size(value: &M) -> u32 { + value.get_cached_size() + } + + fn write_with_cached_size( + field_number: u32, + value: &Self::Value, + os: &mut CodedOutputStream, + ) -> ProtobufResult<()> { + os.write_tag(field_number, WireType::WireTypeLengthDelimited)?; + os.write_raw_varint32(value.get_cached_size())?; + value.write_to_with_cached_sizes(os)?; + Ok(()) + } +} diff --git a/third_party/protobuf/src/unknown.rs b/third_party/protobuf/src/unknown.rs new file mode 100644 index 000000000..f2d9e00e8 --- /dev/null +++ b/third_party/protobuf/src/unknown.rs @@ -0,0 +1,212 @@ +use std::collections::HashMap; +use std::collections::hash_map; +use std::default::Default; +use std::slice; +use stream::wire_format; +use clear::Clear; +use std::boxed::Box; +use std::vec::Vec; + +#[derive(Debug)] +pub enum UnknownValue { + Fixed32(u32), + Fixed64(u64), + Varint(u64), + LengthDelimited(Vec), +} + +impl UnknownValue { + pub fn wire_type(&self) -> wire_format::WireType { + self.get_ref().wire_type() + } + + pub fn get_ref<'s>(&'s self) -> UnknownValueRef<'s> { + match *self { + UnknownValue::Fixed32(fixed32) => UnknownValueRef::Fixed32(fixed32), + UnknownValue::Fixed64(fixed64) => UnknownValueRef::Fixed64(fixed64), + UnknownValue::Varint(varint) => UnknownValueRef::Varint(varint), + UnknownValue::LengthDelimited(ref bytes) => UnknownValueRef::LengthDelimited(&bytes), + } + } +} + +pub enum UnknownValueRef<'o> { + Fixed32(u32), + Fixed64(u64), + Varint(u64), + LengthDelimited(&'o [u8]), +} + +impl<'o> UnknownValueRef<'o> { + pub fn wire_type(&self) -> wire_format::WireType { + match *self { + UnknownValueRef::Fixed32(_) => wire_format::WireTypeFixed32, + UnknownValueRef::Fixed64(_) => wire_format::WireTypeFixed64, + UnknownValueRef::Varint(_) => wire_format::WireTypeVarint, + UnknownValueRef::LengthDelimited(_) => wire_format::WireTypeLengthDelimited, + } + } +} + +#[derive(Clone, PartialEq, Eq, Debug, Default)] +pub struct UnknownValues { + pub fixed32: Vec, + pub fixed64: Vec, + pub varint: Vec, + pub length_delimited: Vec>, +} + +impl UnknownValues { + pub fn add_value(&mut self, value: UnknownValue) { + match value { + UnknownValue::Fixed64(fixed64) => self.fixed64.push(fixed64), + UnknownValue::Fixed32(fixed32) => self.fixed32.push(fixed32), + UnknownValue::Varint(varint) => self.varint.push(varint), + UnknownValue::LengthDelimited(length_delimited) => { + self.length_delimited.push(length_delimited) + } + }; + } + + pub fn iter<'s>(&'s self) -> UnknownValuesIter<'s> { + UnknownValuesIter { + fixed32: self.fixed32.iter(), + fixed64: self.fixed64.iter(), + varint: self.varint.iter(), + length_delimited: self.length_delimited.iter(), + } + } +} + +impl<'a> IntoIterator for &'a UnknownValues { + type Item = UnknownValueRef<'a>; + type IntoIter = UnknownValuesIter<'a>; + + fn into_iter(self) -> UnknownValuesIter<'a> { + self.iter() + } +} + +pub struct UnknownValuesIter<'o> { + fixed32: slice::Iter<'o, u32>, + fixed64: slice::Iter<'o, u64>, + varint: slice::Iter<'o, u64>, + length_delimited: slice::Iter<'o, Vec>, +} + +impl<'o> Iterator for UnknownValuesIter<'o> { + type Item = UnknownValueRef<'o>; + + fn next(&mut self) -> Option> { + let fixed32 = self.fixed32.next(); + if fixed32.is_some() { + return Some(UnknownValueRef::Fixed32(*fixed32.unwrap())); + } + let fixed64 = self.fixed64.next(); + if fixed64.is_some() { + return Some(UnknownValueRef::Fixed64(*fixed64.unwrap())); + } + let varint = self.varint.next(); + if varint.is_some() { + return Some(UnknownValueRef::Varint(*varint.unwrap())); + } + let length_delimited = self.length_delimited.next(); + if length_delimited.is_some() { + return Some(UnknownValueRef::LengthDelimited(&length_delimited.unwrap())); + } + None + } +} + +#[derive(Clone, PartialEq, Eq, Debug, Default)] +pub struct UnknownFields { + // option is needed, because HashMap constructor performs allocation, + // and very expensive + pub fields: Option>>, +} + +impl UnknownFields { + pub fn new() -> UnknownFields { + Default::default() + } + + fn init_map(&mut self) { + if self.fields.is_none() { + self.fields = Some(Default::default()); + } + } + + fn find_field<'a>(&'a mut self, number: &'a u32) -> &'a mut UnknownValues { + self.init_map(); + + match self.fields.as_mut().unwrap().entry(*number) { + hash_map::Entry::Occupied(e) => e.into_mut(), + hash_map::Entry::Vacant(e) => e.insert(Default::default()), + } + } + + pub fn add_fixed32(&mut self, number: u32, fixed32: u32) { + self.find_field(&number).fixed32.push(fixed32); + } + + pub fn add_fixed64(&mut self, number: u32, fixed64: u64) { + self.find_field(&number).fixed64.push(fixed64); + } + + pub fn add_varint(&mut self, number: u32, varint: u64) { + self.find_field(&number).varint.push(varint); + } + + pub fn add_length_delimited(&mut self, number: u32, length_delimited: Vec) { + self.find_field(&number) + .length_delimited + .push(length_delimited); + } + + pub fn add_value(&mut self, number: u32, value: UnknownValue) { + self.find_field(&number).add_value(value); + } + + pub fn iter<'s>(&'s self) -> UnknownFieldsIter<'s> { + UnknownFieldsIter { entries: self.fields.as_ref().map(|m| m.iter()) } + } + + pub fn get(&self, field_number: u32) -> Option<&UnknownValues> { + match self.fields { + Some(ref map) => map.get(&field_number), + None => None, + } + } +} + +impl Clear for UnknownFields { + fn clear(&mut self) { + if let Some(ref mut fields) = self.fields { + fields.clear(); + } + } +} + +impl<'a> IntoIterator for &'a UnknownFields { + type Item = (u32, &'a UnknownValues); + type IntoIter = UnknownFieldsIter<'a>; + + fn into_iter(self) -> UnknownFieldsIter<'a> { + self.iter() + } +} + +pub struct UnknownFieldsIter<'s> { + entries: Option>, +} + +impl<'s> Iterator for UnknownFieldsIter<'s> { + type Item = (u32, &'s UnknownValues); + + fn next(&mut self) -> Option<(u32, &'s UnknownValues)> { + match self.entries { + Some(ref mut entries) => entries.next().map(|(&number, values)| (number, values)), + None => None, + } + } +} diff --git a/third_party/protobuf/src/varint.rs b/third_party/protobuf/src/varint.rs new file mode 100644 index 000000000..1f1cb1c21 --- /dev/null +++ b/third_party/protobuf/src/varint.rs @@ -0,0 +1,35 @@ +/// Encode u64 as varint. +/// Panics if buffer length is less than 10. +#[inline] +pub fn encode_varint64(mut value: u64, buf: &mut [u8]) -> usize { + assert!(buf.len() >= 10); + + unsafe { + let mut i = 0; + while (value & !0x7F) > 0 { + *buf.get_unchecked_mut(i) = ((value & 0x7F) | 0x80) as u8; + value >>= 7; + i += 1; + } + *buf.get_unchecked_mut(i) = value as u8; + i + 1 + } +} + +/// Encode u32 value as varint. +/// Panics if buffer length is less than 5. +#[inline] +pub fn encode_varint32(mut value: u32, buf: &mut [u8]) -> usize { + assert!(buf.len() >= 5); + + unsafe { + let mut i = 0; + while (value & !0x7F) > 0 { + *buf.get_unchecked_mut(i) = ((value & 0x7F) | 0x80) as u8; + value >>= 7; + i += 1; + } + *buf.get_unchecked_mut(i) = value as u8; + i + 1 + } +} diff --git a/third_party/protobuf/src/well_known_types/any.rs b/third_party/protobuf/src/well_known_types/any.rs new file mode 100644 index 000000000..2a6a640b2 --- /dev/null +++ b/third_party/protobuf/src/well_known_types/any.rs @@ -0,0 +1,409 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +use std::boxed::Box; + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +#[derive(PartialEq,Clone,Default)] +pub struct Any { + // message fields + pub type_url: ::std::string::String, + pub value: ::std::vec::Vec, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for Any {} + +impl Any { + pub fn new() -> Any { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static Any { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Any, + }; + unsafe { + instance.get(Any::new) + } + } + + // string type_url = 1; + + pub fn clear_type_url(&mut self) { + self.type_url.clear(); + } + + // Param is passed by value, moved + pub fn set_type_url(&mut self, v: ::std::string::String) { + self.type_url = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_type_url(&mut self) -> &mut ::std::string::String { + &mut self.type_url + } + + // Take field + pub fn take_type_url(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.type_url, ::std::string::String::new()) + } + + pub fn get_type_url(&self) -> &str { + &self.type_url + } + + fn get_type_url_for_reflect(&self) -> &::std::string::String { + &self.type_url + } + + fn mut_type_url_for_reflect(&mut self) -> &mut ::std::string::String { + &mut self.type_url + } + + // bytes value = 2; + + pub fn clear_value(&mut self) { + self.value.clear(); + } + + // Param is passed by value, moved + pub fn set_value(&mut self, v: ::std::vec::Vec) { + self.value = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_value(&mut self) -> &mut ::std::vec::Vec { + &mut self.value + } + + // Take field + pub fn take_value(&mut self) -> ::std::vec::Vec { + ::std::mem::replace(&mut self.value, ::std::vec::Vec::new()) + } + + pub fn get_value(&self) -> &[u8] { + &self.value + } + + fn get_value_for_reflect(&self) -> &::std::vec::Vec { + &self.value + } + + fn mut_value_for_reflect(&mut self) -> &mut ::std::vec::Vec { + &mut self.value + } +} + +impl ::protobuf::Message for Any { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.type_url)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_bytes_into(wire_type, is, &mut self.value)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.type_url.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.type_url); + } + if !self.value.is_empty() { + my_size += ::protobuf::rt::bytes_size(2, &self.value); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.type_url.is_empty() { + os.write_string(1, &self.type_url)?; + } + if !self.value.is_empty() { + os.write_bytes(2, &self.value)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for Any { + fn new() -> Any { + Any::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "type_url", + Any::get_type_url_for_reflect, + Any::mut_type_url_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>( + "value", + Any::get_value_for_reflect, + Any::mut_value_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Any", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for Any { + fn clear(&mut self) { + self.clear_type_url(); + self.clear_value(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Any { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Any { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x19google/protobuf/any.proto\x12\x0fgoogle.protobuf\"6\n\x03Any\x12\ + \x19\n\x08type_url\x18\x01\x20\x01(\tR\x07typeUrl\x12\x14\n\x05value\x18\ + \x02\x20\x01(\x0cR\x05valueBo\n\x13com.google.protobufB\x08AnyProtoP\x01\ + Z%github.com/golang/protobuf/ptypes/any\xa2\x02\x03GPB\xaa\x02\x1eGoogle\ + .Protobuf.WellKnownTypesJ\x99)\n\x07\x12\x05\x1e\0\x8a\x01\x01\n\xcc\x0c\ + \n\x01\x0c\x12\x03\x1e\0\x122\xc1\x0c\x20Protocol\x20Buffers\x20-\x20Goo\ + gle's\x20data\x20interchange\x20format\n\x20Copyright\x202008\x20Google\ + \x20Inc.\x20\x20All\x20rights\x20reserved.\n\x20https://developers.googl\ + e.com/protocol-buffers/\n\n\x20Redistribution\x20and\x20use\x20in\x20sou\ + rce\x20and\x20binary\x20forms,\x20with\x20or\x20without\n\x20modificatio\ + n,\x20are\x20permitted\x20provided\x20that\x20the\x20following\x20condit\ + ions\x20are\n\x20met:\n\n\x20\x20\x20\x20\x20*\x20Redistributions\x20of\ + \x20source\x20code\x20must\x20retain\x20the\x20above\x20copyright\n\x20n\ + otice,\x20this\x20list\x20of\x20conditions\x20and\x20the\x20following\ + \x20disclaimer.\n\x20\x20\x20\x20\x20*\x20Redistributions\x20in\x20binar\ + y\x20form\x20must\x20reproduce\x20the\x20above\n\x20copyright\x20notice,\ + \x20this\x20list\x20of\x20conditions\x20and\x20the\x20following\x20discl\ + aimer\n\x20in\x20the\x20documentation\x20and/or\x20other\x20materials\ + \x20provided\x20with\x20the\n\x20distribution.\n\x20\x20\x20\x20\x20*\ + \x20Neither\x20the\x20name\x20of\x20Google\x20Inc.\x20nor\x20the\x20name\ + s\x20of\x20its\n\x20contributors\x20may\x20be\x20used\x20to\x20endorse\ + \x20or\x20promote\x20products\x20derived\x20from\n\x20this\x20software\ + \x20without\x20specific\x20prior\x20written\x20permission.\n\n\x20THIS\ + \x20SOFTWARE\x20IS\x20PROVIDED\x20BY\x20THE\x20COPYRIGHT\x20HOLDERS\x20A\ + ND\x20CONTRIBUTORS\n\x20\"AS\x20IS\"\x20AND\x20ANY\x20EXPRESS\x20OR\x20I\ + MPLIED\x20WARRANTIES,\x20INCLUDING,\x20BUT\x20NOT\n\x20LIMITED\x20TO,\ + \x20THE\x20IMPLIED\x20WARRANTIES\x20OF\x20MERCHANTABILITY\x20AND\x20FITN\ + ESS\x20FOR\n\x20A\x20PARTICULAR\x20PURPOSE\x20ARE\x20DISCLAIMED.\x20IN\ + \x20NO\x20EVENT\x20SHALL\x20THE\x20COPYRIGHT\n\x20OWNER\x20OR\x20CONTRIB\ + UTORS\x20BE\x20LIABLE\x20FOR\x20ANY\x20DIRECT,\x20INDIRECT,\x20INCIDENTA\ + L,\n\x20SPECIAL,\x20EXEMPLARY,\x20OR\x20CONSEQUENTIAL\x20DAMAGES\x20(INC\ + LUDING,\x20BUT\x20NOT\n\x20LIMITED\x20TO,\x20PROCUREMENT\x20OF\x20SUBSTI\ + TUTE\x20GOODS\x20OR\x20SERVICES;\x20LOSS\x20OF\x20USE,\n\x20DATA,\x20OR\ + \x20PROFITS;\x20OR\x20BUSINESS\x20INTERRUPTION)\x20HOWEVER\x20CAUSED\x20\ + AND\x20ON\x20ANY\n\x20THEORY\x20OF\x20LIABILITY,\x20WHETHER\x20IN\x20CON\ + TRACT,\x20STRICT\x20LIABILITY,\x20OR\x20TORT\n\x20(INCLUDING\x20NEGLIGEN\ + CE\x20OR\x20OTHERWISE)\x20ARISING\x20IN\x20ANY\x20WAY\x20OUT\x20OF\x20TH\ + E\x20USE\n\x20OF\x20THIS\x20SOFTWARE,\x20EVEN\x20IF\x20ADVISED\x20OF\x20\ + THE\x20POSSIBILITY\x20OF\x20SUCH\x20DAMAGE.\n\n\x08\n\x01\x02\x12\x03\ + \x20\x08\x17\n\x08\n\x01\x08\x12\x03\"\0;\n\x0b\n\x04\x08\xe7\x07\0\x12\ + \x03\"\0;\n\x0c\n\x05\x08\xe7\x07\0\x02\x12\x03\"\x07\x17\n\r\n\x06\x08\ + \xe7\x07\0\x02\0\x12\x03\"\x07\x17\n\x0e\n\x07\x08\xe7\x07\0\x02\0\x01\ + \x12\x03\"\x07\x17\n\x0c\n\x05\x08\xe7\x07\0\x07\x12\x03\"\x1a:\n\x08\n\ + \x01\x08\x12\x03#\0<\n\x0b\n\x04\x08\xe7\x07\x01\x12\x03#\0<\n\x0c\n\x05\ + \x08\xe7\x07\x01\x02\x12\x03#\x07\x11\n\r\n\x06\x08\xe7\x07\x01\x02\0\ + \x12\x03#\x07\x11\n\x0e\n\x07\x08\xe7\x07\x01\x02\0\x01\x12\x03#\x07\x11\ + \n\x0c\n\x05\x08\xe7\x07\x01\x07\x12\x03#\x14;\n\x08\n\x01\x08\x12\x03$\ + \0,\n\x0b\n\x04\x08\xe7\x07\x02\x12\x03$\0,\n\x0c\n\x05\x08\xe7\x07\x02\ + \x02\x12\x03$\x07\x13\n\r\n\x06\x08\xe7\x07\x02\x02\0\x12\x03$\x07\x13\n\ + \x0e\n\x07\x08\xe7\x07\x02\x02\0\x01\x12\x03$\x07\x13\n\x0c\n\x05\x08\ + \xe7\x07\x02\x07\x12\x03$\x16+\n\x08\n\x01\x08\x12\x03%\0)\n\x0b\n\x04\ + \x08\xe7\x07\x03\x12\x03%\0)\n\x0c\n\x05\x08\xe7\x07\x03\x02\x12\x03%\ + \x07\x1b\n\r\n\x06\x08\xe7\x07\x03\x02\0\x12\x03%\x07\x1b\n\x0e\n\x07\ + \x08\xe7\x07\x03\x02\0\x01\x12\x03%\x07\x1b\n\x0c\n\x05\x08\xe7\x07\x03\ + \x07\x12\x03%\x1e(\n\x08\n\x01\x08\x12\x03&\0\"\n\x0b\n\x04\x08\xe7\x07\ + \x04\x12\x03&\0\"\n\x0c\n\x05\x08\xe7\x07\x04\x02\x12\x03&\x07\x1a\n\r\n\ + \x06\x08\xe7\x07\x04\x02\0\x12\x03&\x07\x1a\n\x0e\n\x07\x08\xe7\x07\x04\ + \x02\0\x01\x12\x03&\x07\x1a\n\x0c\n\x05\x08\xe7\x07\x04\x03\x12\x03&\x1d\ + !\n\x08\n\x01\x08\x12\x03'\0!\n\x0b\n\x04\x08\xe7\x07\x05\x12\x03'\0!\n\ + \x0c\n\x05\x08\xe7\x07\x05\x02\x12\x03'\x07\x18\n\r\n\x06\x08\xe7\x07\ + \x05\x02\0\x12\x03'\x07\x18\n\x0e\n\x07\x08\xe7\x07\x05\x02\0\x01\x12\ + \x03'\x07\x18\n\x0c\n\x05\x08\xe7\x07\x05\x07\x12\x03'\x1b\x20\n\x81\x0f\ + \n\x02\x04\0\x12\x05o\0\x8a\x01\x01\x1a\xf3\x0e\x20`Any`\x20contains\x20\ + an\x20arbitrary\x20serialized\x20protocol\x20buffer\x20message\x20along\ + \x20with\x20a\n\x20URL\x20that\x20describes\x20the\x20type\x20of\x20the\ + \x20serialized\x20message.\n\n\x20Protobuf\x20library\x20provides\x20sup\ + port\x20to\x20pack/unpack\x20Any\x20values\x20in\x20the\x20form\n\x20of\ + \x20utility\x20functions\x20or\x20additional\x20generated\x20methods\x20\ + of\x20the\x20Any\x20type.\n\n\x20Example\x201:\x20Pack\x20and\x20unpack\ + \x20a\x20message\x20in\x20C++.\n\n\x20\x20\x20\x20\x20Foo\x20foo\x20=\ + \x20...;\n\x20\x20\x20\x20\x20Any\x20any;\n\x20\x20\x20\x20\x20any.PackF\ + rom(foo);\n\x20\x20\x20\x20\x20...\n\x20\x20\x20\x20\x20if\x20(any.Unpac\ + kTo(&foo))\x20{\n\x20\x20\x20\x20\x20\x20\x20...\n\x20\x20\x20\x20\x20}\ + \n\n\x20Example\x202:\x20Pack\x20and\x20unpack\x20a\x20message\x20in\x20\ + Java.\n\n\x20\x20\x20\x20\x20Foo\x20foo\x20=\x20...;\n\x20\x20\x20\x20\ + \x20Any\x20any\x20=\x20Any.pack(foo);\n\x20\x20\x20\x20\x20...\n\x20\x20\ + \x20\x20\x20if\x20(any.is(Foo.class))\x20{\n\x20\x20\x20\x20\x20\x20\x20\ + foo\x20=\x20any.unpack(Foo.class);\n\x20\x20\x20\x20\x20}\n\n\x20\x20Exa\ + mple\x203:\x20Pack\x20and\x20unpack\x20a\x20message\x20in\x20Python.\n\n\ + \x20\x20\x20\x20\x20foo\x20=\x20Foo(...)\n\x20\x20\x20\x20\x20any\x20=\ + \x20Any()\n\x20\x20\x20\x20\x20any.Pack(foo)\n\x20\x20\x20\x20\x20...\n\ + \x20\x20\x20\x20\x20if\x20any.Is(Foo.DESCRIPTOR):\n\x20\x20\x20\x20\x20\ + \x20\x20any.Unpack(foo)\n\x20\x20\x20\x20\x20\x20\x20...\n\n\x20The\x20p\ + ack\x20methods\x20provided\x20by\x20protobuf\x20library\x20will\x20by\ + \x20default\x20use\n\x20'type.googleapis.com/full.type.name'\x20as\x20th\ + e\x20type\x20URL\x20and\x20the\x20unpack\n\x20methods\x20only\x20use\x20\ + the\x20fully\x20qualified\x20type\x20name\x20after\x20the\x20last\x20'/'\ + \n\x20in\x20the\x20type\x20URL,\x20for\x20example\x20\"foo.bar.com/x/y.z\ + \"\x20will\x20yield\x20type\n\x20name\x20\"y.z\".\n\n\n\x20JSON\n\x20===\ + =\n\x20The\x20JSON\x20representation\x20of\x20an\x20`Any`\x20value\x20us\ + es\x20the\x20regular\n\x20representation\x20of\x20the\x20deserialized,\ + \x20embedded\x20message,\x20with\x20an\n\x20additional\x20field\x20`@typ\ + e`\x20which\x20contains\x20the\x20type\x20URL.\x20Example:\n\n\x20\x20\ + \x20\x20\x20package\x20google.profile;\n\x20\x20\x20\x20\x20message\x20P\ + erson\x20{\n\x20\x20\x20\x20\x20\x20\x20string\x20first_name\x20=\x201;\ + \n\x20\x20\x20\x20\x20\x20\x20string\x20last_name\x20=\x202;\n\x20\x20\ + \x20\x20\x20}\n\n\x20\x20\x20\x20\x20{\n\x20\x20\x20\x20\x20\x20\x20\"@t\ + ype\":\x20\"type.googleapis.com/google.profile.Person\",\n\x20\x20\x20\ + \x20\x20\x20\x20\"firstName\":\x20,\n\x20\x20\x20\x20\x20\x20\ + \x20\"lastName\":\x20\n\x20\x20\x20\x20\x20}\n\n\x20If\x20the\ + \x20embedded\x20message\x20type\x20is\x20well-known\x20and\x20has\x20a\ + \x20custom\x20JSON\n\x20representation,\x20that\x20representation\x20wil\ + l\x20be\x20embedded\x20adding\x20a\x20field\n\x20`value`\x20which\x20hol\ + ds\x20the\x20custom\x20JSON\x20in\x20addition\x20to\x20the\x20`@type`\n\ + \x20field.\x20Example\x20(for\x20message\x20[google.protobuf.Duration][]\ + ):\n\n\x20\x20\x20\x20\x20{\n\x20\x20\x20\x20\x20\x20\x20\"@type\":\x20\ + \"type.googleapis.com/google.protobuf.Duration\",\n\x20\x20\x20\x20\x20\ + \x20\x20\"value\":\x20\"1.212s\"\n\x20\x20\x20\x20\x20}\n\n\n\n\n\x03\ + \x04\0\x01\x12\x03o\x08\x0b\n\xe4\x07\n\x04\x04\0\x02\0\x12\x04\x86\x01\ + \x02\x16\x1a\xd5\x07\x20A\x20URL/resource\x20name\x20whose\x20content\ + \x20describes\x20the\x20type\x20of\x20the\n\x20serialized\x20protocol\ + \x20buffer\x20message.\n\n\x20For\x20URLs\x20which\x20use\x20the\x20sche\ + me\x20`http`,\x20`https`,\x20or\x20no\x20scheme,\x20the\n\x20following\ + \x20restrictions\x20and\x20interpretations\x20apply:\n\n\x20*\x20If\x20n\ + o\x20scheme\x20is\x20provided,\x20`https`\x20is\x20assumed.\n\x20*\x20Th\ + e\x20last\x20segment\x20of\x20the\x20URL's\x20path\x20must\x20represent\ + \x20the\x20fully\n\x20\x20\x20qualified\x20name\x20of\x20the\x20type\x20\ + (as\x20in\x20`path/google.protobuf.Duration`).\n\x20\x20\x20The\x20name\ + \x20should\x20be\x20in\x20a\x20canonical\x20form\x20(e.g.,\x20leading\ + \x20\".\"\x20is\n\x20\x20\x20not\x20accepted).\n\x20*\x20An\x20HTTP\x20G\ + ET\x20on\x20the\x20URL\x20must\x20yield\x20a\x20[google.protobuf.Type][]\ + \n\x20\x20\x20value\x20in\x20binary\x20format,\x20or\x20produce\x20an\ + \x20error.\n\x20*\x20Applications\x20are\x20allowed\x20to\x20cache\x20lo\ + okup\x20results\x20based\x20on\x20the\n\x20\x20\x20URL,\x20or\x20have\ + \x20them\x20precompiled\x20into\x20a\x20binary\x20to\x20avoid\x20any\n\ + \x20\x20\x20lookup.\x20Therefore,\x20binary\x20compatibility\x20needs\ + \x20to\x20be\x20preserved\n\x20\x20\x20on\x20changes\x20to\x20types.\x20\ + (Use\x20versioned\x20type\x20names\x20to\x20manage\n\x20\x20\x20breaking\ + \x20changes.)\n\n\x20Schemes\x20other\x20than\x20`http`,\x20`https`\x20(\ + or\x20the\x20empty\x20scheme)\x20might\x20be\n\x20used\x20with\x20implem\ + entation\x20specific\x20semantics.\n\n\n\x0e\n\x05\x04\0\x02\0\x04\x12\ + \x05\x86\x01\x02o\r\n\r\n\x05\x04\0\x02\0\x05\x12\x04\x86\x01\x02\x08\n\ + \r\n\x05\x04\0\x02\0\x01\x12\x04\x86\x01\t\x11\n\r\n\x05\x04\0\x02\0\x03\ + \x12\x04\x86\x01\x14\x15\nW\n\x04\x04\0\x02\x01\x12\x04\x89\x01\x02\x12\ + \x1aI\x20Must\x20be\x20a\x20valid\x20serialized\x20protocol\x20buffer\ + \x20of\x20the\x20above\x20specified\x20type.\n\n\x0f\n\x05\x04\0\x02\x01\ + \x04\x12\x06\x89\x01\x02\x86\x01\x16\n\r\n\x05\x04\0\x02\x01\x05\x12\x04\ + \x89\x01\x02\x07\n\r\n\x05\x04\0\x02\x01\x01\x12\x04\x89\x01\x08\r\n\r\n\ + \x05\x04\0\x02\x01\x03\x12\x04\x89\x01\x10\x11b\x06proto3\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/third_party/protobuf/src/well_known_types/api.rs b/third_party/protobuf/src/well_known_types/api.rs new file mode 100644 index 000000000..700ee4a96 --- /dev/null +++ b/third_party/protobuf/src/well_known_types/api.rs @@ -0,0 +1,1465 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +use std::boxed::Box; + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +#[derive(PartialEq,Clone,Default)] +pub struct Api { + // message fields + pub name: ::std::string::String, + pub methods: ::protobuf::RepeatedField, + pub options: ::protobuf::RepeatedField<::protobuf::well_known_types::Option>, + pub version: ::std::string::String, + pub source_context: ::protobuf::SingularPtrField<::protobuf::well_known_types::SourceContext>, + pub mixins: ::protobuf::RepeatedField, + pub syntax: ::protobuf::well_known_types::Syntax, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for Api {} + +impl Api { + pub fn new() -> Api { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static Api { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Api, + }; + unsafe { + instance.get(Api::new) + } + } + + // string name = 1; + + pub fn clear_name(&mut self) { + self.name.clear(); + } + + // Param is passed by value, moved + pub fn set_name(&mut self, v: ::std::string::String) { + self.name = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_name(&mut self) -> &mut ::std::string::String { + &mut self.name + } + + // Take field + pub fn take_name(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.name, ::std::string::String::new()) + } + + pub fn get_name(&self) -> &str { + &self.name + } + + fn get_name_for_reflect(&self) -> &::std::string::String { + &self.name + } + + fn mut_name_for_reflect(&mut self) -> &mut ::std::string::String { + &mut self.name + } + + // repeated .google.protobuf.Method methods = 2; + + pub fn clear_methods(&mut self) { + self.methods.clear(); + } + + // Param is passed by value, moved + pub fn set_methods(&mut self, v: ::protobuf::RepeatedField) { + self.methods = v; + } + + // Mutable pointer to the field. + pub fn mut_methods(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.methods + } + + // Take field + pub fn take_methods(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.methods, ::protobuf::RepeatedField::new()) + } + + pub fn get_methods(&self) -> &[Method] { + &self.methods + } + + fn get_methods_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.methods + } + + fn mut_methods_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.methods + } + + // repeated .google.protobuf.Option options = 3; + + pub fn clear_options(&mut self) { + self.options.clear(); + } + + // Param is passed by value, moved + pub fn set_options(&mut self, v: ::protobuf::RepeatedField<::protobuf::well_known_types::Option>) { + self.options = v; + } + + // Mutable pointer to the field. + pub fn mut_options(&mut self) -> &mut ::protobuf::RepeatedField<::protobuf::well_known_types::Option> { + &mut self.options + } + + // Take field + pub fn take_options(&mut self) -> ::protobuf::RepeatedField<::protobuf::well_known_types::Option> { + ::std::mem::replace(&mut self.options, ::protobuf::RepeatedField::new()) + } + + pub fn get_options(&self) -> &[::protobuf::well_known_types::Option] { + &self.options + } + + fn get_options_for_reflect(&self) -> &::protobuf::RepeatedField<::protobuf::well_known_types::Option> { + &self.options + } + + fn mut_options_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField<::protobuf::well_known_types::Option> { + &mut self.options + } + + // string version = 4; + + pub fn clear_version(&mut self) { + self.version.clear(); + } + + // Param is passed by value, moved + pub fn set_version(&mut self, v: ::std::string::String) { + self.version = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_version(&mut self) -> &mut ::std::string::String { + &mut self.version + } + + // Take field + pub fn take_version(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.version, ::std::string::String::new()) + } + + pub fn get_version(&self) -> &str { + &self.version + } + + fn get_version_for_reflect(&self) -> &::std::string::String { + &self.version + } + + fn mut_version_for_reflect(&mut self) -> &mut ::std::string::String { + &mut self.version + } + + // .google.protobuf.SourceContext source_context = 5; + + pub fn clear_source_context(&mut self) { + self.source_context.clear(); + } + + pub fn has_source_context(&self) -> bool { + self.source_context.is_some() + } + + // Param is passed by value, moved + pub fn set_source_context(&mut self, v: ::protobuf::well_known_types::SourceContext) { + self.source_context = ::protobuf::SingularPtrField::some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_source_context(&mut self) -> &mut ::protobuf::well_known_types::SourceContext { + if self.source_context.is_none() { + self.source_context.set_default(); + } + self.source_context.as_mut().unwrap() + } + + // Take field + pub fn take_source_context(&mut self) -> ::protobuf::well_known_types::SourceContext { + self.source_context.take().unwrap_or_else(|| ::protobuf::well_known_types::SourceContext::new()) + } + + pub fn get_source_context(&self) -> &::protobuf::well_known_types::SourceContext { + self.source_context.as_ref().unwrap_or_else(|| ::protobuf::well_known_types::SourceContext::default_instance()) + } + + fn get_source_context_for_reflect(&self) -> &::protobuf::SingularPtrField<::protobuf::well_known_types::SourceContext> { + &self.source_context + } + + fn mut_source_context_for_reflect(&mut self) -> &mut ::protobuf::SingularPtrField<::protobuf::well_known_types::SourceContext> { + &mut self.source_context + } + + // repeated .google.protobuf.Mixin mixins = 6; + + pub fn clear_mixins(&mut self) { + self.mixins.clear(); + } + + // Param is passed by value, moved + pub fn set_mixins(&mut self, v: ::protobuf::RepeatedField) { + self.mixins = v; + } + + // Mutable pointer to the field. + pub fn mut_mixins(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.mixins + } + + // Take field + pub fn take_mixins(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.mixins, ::protobuf::RepeatedField::new()) + } + + pub fn get_mixins(&self) -> &[Mixin] { + &self.mixins + } + + fn get_mixins_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.mixins + } + + fn mut_mixins_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.mixins + } + + // .google.protobuf.Syntax syntax = 7; + + pub fn clear_syntax(&mut self) { + self.syntax = ::protobuf::well_known_types::Syntax::SYNTAX_PROTO2; + } + + // Param is passed by value, moved + pub fn set_syntax(&mut self, v: ::protobuf::well_known_types::Syntax) { + self.syntax = v; + } + + pub fn get_syntax(&self) -> ::protobuf::well_known_types::Syntax { + self.syntax + } + + fn get_syntax_for_reflect(&self) -> &::protobuf::well_known_types::Syntax { + &self.syntax + } + + fn mut_syntax_for_reflect(&mut self) -> &mut ::protobuf::well_known_types::Syntax { + &mut self.syntax + } +} + +impl ::protobuf::Message for Api { + fn is_initialized(&self) -> bool { + for v in &self.methods { + if !v.is_initialized() { + return false; + } + }; + for v in &self.options { + if !v.is_initialized() { + return false; + } + }; + for v in &self.source_context { + if !v.is_initialized() { + return false; + } + }; + for v in &self.mixins { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.name)?; + }, + 2 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.methods)?; + }, + 3 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.options)?; + }, + 4 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.version)?; + }, + 5 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.source_context)?; + }, + 6 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.mixins)?; + }, + 7 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_enum()?; + self.syntax = tmp; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.name.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.name); + } + for value in &self.methods { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + for value in &self.options { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + if !self.version.is_empty() { + my_size += ::protobuf::rt::string_size(4, &self.version); + } + if let Some(ref v) = self.source_context.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } + for value in &self.mixins { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + if self.syntax != ::protobuf::well_known_types::Syntax::SYNTAX_PROTO2 { + my_size += ::protobuf::rt::enum_size(7, self.syntax); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.name.is_empty() { + os.write_string(1, &self.name)?; + } + for v in &self.methods { + os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + for v in &self.options { + os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + if !self.version.is_empty() { + os.write_string(4, &self.version)?; + } + if let Some(ref v) = self.source_context.as_ref() { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } + for v in &self.mixins { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + if self.syntax != ::protobuf::well_known_types::Syntax::SYNTAX_PROTO2 { + os.write_enum(7, self.syntax.value())?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for Api { + fn new() -> Api { + Api::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "name", + Api::get_name_for_reflect, + Api::mut_name_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "methods", + Api::get_methods_for_reflect, + Api::mut_methods_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<::protobuf::well_known_types::Option>>( + "options", + Api::get_options_for_reflect, + Api::mut_options_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "version", + Api::get_version_for_reflect, + Api::mut_version_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<::protobuf::well_known_types::SourceContext>>( + "source_context", + Api::get_source_context_for_reflect, + Api::mut_source_context_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "mixins", + Api::get_mixins_for_reflect, + Api::mut_mixins_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum<::protobuf::well_known_types::Syntax>>( + "syntax", + Api::get_syntax_for_reflect, + Api::mut_syntax_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Api", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for Api { + fn clear(&mut self) { + self.clear_name(); + self.clear_methods(); + self.clear_options(); + self.clear_version(); + self.clear_source_context(); + self.clear_mixins(); + self.clear_syntax(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Api { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Api { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Method { + // message fields + pub name: ::std::string::String, + pub request_type_url: ::std::string::String, + pub request_streaming: bool, + pub response_type_url: ::std::string::String, + pub response_streaming: bool, + pub options: ::protobuf::RepeatedField<::protobuf::well_known_types::Option>, + pub syntax: ::protobuf::well_known_types::Syntax, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for Method {} + +impl Method { + pub fn new() -> Method { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static Method { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Method, + }; + unsafe { + instance.get(Method::new) + } + } + + // string name = 1; + + pub fn clear_name(&mut self) { + self.name.clear(); + } + + // Param is passed by value, moved + pub fn set_name(&mut self, v: ::std::string::String) { + self.name = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_name(&mut self) -> &mut ::std::string::String { + &mut self.name + } + + // Take field + pub fn take_name(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.name, ::std::string::String::new()) + } + + pub fn get_name(&self) -> &str { + &self.name + } + + fn get_name_for_reflect(&self) -> &::std::string::String { + &self.name + } + + fn mut_name_for_reflect(&mut self) -> &mut ::std::string::String { + &mut self.name + } + + // string request_type_url = 2; + + pub fn clear_request_type_url(&mut self) { + self.request_type_url.clear(); + } + + // Param is passed by value, moved + pub fn set_request_type_url(&mut self, v: ::std::string::String) { + self.request_type_url = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_request_type_url(&mut self) -> &mut ::std::string::String { + &mut self.request_type_url + } + + // Take field + pub fn take_request_type_url(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.request_type_url, ::std::string::String::new()) + } + + pub fn get_request_type_url(&self) -> &str { + &self.request_type_url + } + + fn get_request_type_url_for_reflect(&self) -> &::std::string::String { + &self.request_type_url + } + + fn mut_request_type_url_for_reflect(&mut self) -> &mut ::std::string::String { + &mut self.request_type_url + } + + // bool request_streaming = 3; + + pub fn clear_request_streaming(&mut self) { + self.request_streaming = false; + } + + // Param is passed by value, moved + pub fn set_request_streaming(&mut self, v: bool) { + self.request_streaming = v; + } + + pub fn get_request_streaming(&self) -> bool { + self.request_streaming + } + + fn get_request_streaming_for_reflect(&self) -> &bool { + &self.request_streaming + } + + fn mut_request_streaming_for_reflect(&mut self) -> &mut bool { + &mut self.request_streaming + } + + // string response_type_url = 4; + + pub fn clear_response_type_url(&mut self) { + self.response_type_url.clear(); + } + + // Param is passed by value, moved + pub fn set_response_type_url(&mut self, v: ::std::string::String) { + self.response_type_url = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_response_type_url(&mut self) -> &mut ::std::string::String { + &mut self.response_type_url + } + + // Take field + pub fn take_response_type_url(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.response_type_url, ::std::string::String::new()) + } + + pub fn get_response_type_url(&self) -> &str { + &self.response_type_url + } + + fn get_response_type_url_for_reflect(&self) -> &::std::string::String { + &self.response_type_url + } + + fn mut_response_type_url_for_reflect(&mut self) -> &mut ::std::string::String { + &mut self.response_type_url + } + + // bool response_streaming = 5; + + pub fn clear_response_streaming(&mut self) { + self.response_streaming = false; + } + + // Param is passed by value, moved + pub fn set_response_streaming(&mut self, v: bool) { + self.response_streaming = v; + } + + pub fn get_response_streaming(&self) -> bool { + self.response_streaming + } + + fn get_response_streaming_for_reflect(&self) -> &bool { + &self.response_streaming + } + + fn mut_response_streaming_for_reflect(&mut self) -> &mut bool { + &mut self.response_streaming + } + + // repeated .google.protobuf.Option options = 6; + + pub fn clear_options(&mut self) { + self.options.clear(); + } + + // Param is passed by value, moved + pub fn set_options(&mut self, v: ::protobuf::RepeatedField<::protobuf::well_known_types::Option>) { + self.options = v; + } + + // Mutable pointer to the field. + pub fn mut_options(&mut self) -> &mut ::protobuf::RepeatedField<::protobuf::well_known_types::Option> { + &mut self.options + } + + // Take field + pub fn take_options(&mut self) -> ::protobuf::RepeatedField<::protobuf::well_known_types::Option> { + ::std::mem::replace(&mut self.options, ::protobuf::RepeatedField::new()) + } + + pub fn get_options(&self) -> &[::protobuf::well_known_types::Option] { + &self.options + } + + fn get_options_for_reflect(&self) -> &::protobuf::RepeatedField<::protobuf::well_known_types::Option> { + &self.options + } + + fn mut_options_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField<::protobuf::well_known_types::Option> { + &mut self.options + } + + // .google.protobuf.Syntax syntax = 7; + + pub fn clear_syntax(&mut self) { + self.syntax = ::protobuf::well_known_types::Syntax::SYNTAX_PROTO2; + } + + // Param is passed by value, moved + pub fn set_syntax(&mut self, v: ::protobuf::well_known_types::Syntax) { + self.syntax = v; + } + + pub fn get_syntax(&self) -> ::protobuf::well_known_types::Syntax { + self.syntax + } + + fn get_syntax_for_reflect(&self) -> &::protobuf::well_known_types::Syntax { + &self.syntax + } + + fn mut_syntax_for_reflect(&mut self) -> &mut ::protobuf::well_known_types::Syntax { + &mut self.syntax + } +} + +impl ::protobuf::Message for Method { + fn is_initialized(&self) -> bool { + for v in &self.options { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.name)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.request_type_url)?; + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.request_streaming = tmp; + }, + 4 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.response_type_url)?; + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.response_streaming = tmp; + }, + 6 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.options)?; + }, + 7 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_enum()?; + self.syntax = tmp; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.name.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.name); + } + if !self.request_type_url.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.request_type_url); + } + if self.request_streaming != false { + my_size += 2; + } + if !self.response_type_url.is_empty() { + my_size += ::protobuf::rt::string_size(4, &self.response_type_url); + } + if self.response_streaming != false { + my_size += 2; + } + for value in &self.options { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + if self.syntax != ::protobuf::well_known_types::Syntax::SYNTAX_PROTO2 { + my_size += ::protobuf::rt::enum_size(7, self.syntax); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.name.is_empty() { + os.write_string(1, &self.name)?; + } + if !self.request_type_url.is_empty() { + os.write_string(2, &self.request_type_url)?; + } + if self.request_streaming != false { + os.write_bool(3, self.request_streaming)?; + } + if !self.response_type_url.is_empty() { + os.write_string(4, &self.response_type_url)?; + } + if self.response_streaming != false { + os.write_bool(5, self.response_streaming)?; + } + for v in &self.options { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + if self.syntax != ::protobuf::well_known_types::Syntax::SYNTAX_PROTO2 { + os.write_enum(7, self.syntax.value())?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for Method { + fn new() -> Method { + Method::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "name", + Method::get_name_for_reflect, + Method::mut_name_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "request_type_url", + Method::get_request_type_url_for_reflect, + Method::mut_request_type_url_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "request_streaming", + Method::get_request_streaming_for_reflect, + Method::mut_request_streaming_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "response_type_url", + Method::get_response_type_url_for_reflect, + Method::mut_response_type_url_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "response_streaming", + Method::get_response_streaming_for_reflect, + Method::mut_response_streaming_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<::protobuf::well_known_types::Option>>( + "options", + Method::get_options_for_reflect, + Method::mut_options_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum<::protobuf::well_known_types::Syntax>>( + "syntax", + Method::get_syntax_for_reflect, + Method::mut_syntax_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Method", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for Method { + fn clear(&mut self) { + self.clear_name(); + self.clear_request_type_url(); + self.clear_request_streaming(); + self.clear_response_type_url(); + self.clear_response_streaming(); + self.clear_options(); + self.clear_syntax(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Method { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Method { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Mixin { + // message fields + pub name: ::std::string::String, + pub root: ::std::string::String, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for Mixin {} + +impl Mixin { + pub fn new() -> Mixin { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static Mixin { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Mixin, + }; + unsafe { + instance.get(Mixin::new) + } + } + + // string name = 1; + + pub fn clear_name(&mut self) { + self.name.clear(); + } + + // Param is passed by value, moved + pub fn set_name(&mut self, v: ::std::string::String) { + self.name = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_name(&mut self) -> &mut ::std::string::String { + &mut self.name + } + + // Take field + pub fn take_name(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.name, ::std::string::String::new()) + } + + pub fn get_name(&self) -> &str { + &self.name + } + + fn get_name_for_reflect(&self) -> &::std::string::String { + &self.name + } + + fn mut_name_for_reflect(&mut self) -> &mut ::std::string::String { + &mut self.name + } + + // string root = 2; + + pub fn clear_root(&mut self) { + self.root.clear(); + } + + // Param is passed by value, moved + pub fn set_root(&mut self, v: ::std::string::String) { + self.root = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_root(&mut self) -> &mut ::std::string::String { + &mut self.root + } + + // Take field + pub fn take_root(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.root, ::std::string::String::new()) + } + + pub fn get_root(&self) -> &str { + &self.root + } + + fn get_root_for_reflect(&self) -> &::std::string::String { + &self.root + } + + fn mut_root_for_reflect(&mut self) -> &mut ::std::string::String { + &mut self.root + } +} + +impl ::protobuf::Message for Mixin { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.name)?; + }, + 2 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.root)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.name.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.name); + } + if !self.root.is_empty() { + my_size += ::protobuf::rt::string_size(2, &self.root); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.name.is_empty() { + os.write_string(1, &self.name)?; + } + if !self.root.is_empty() { + os.write_string(2, &self.root)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for Mixin { + fn new() -> Mixin { + Mixin::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "name", + Mixin::get_name_for_reflect, + Mixin::mut_name_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "root", + Mixin::get_root_for_reflect, + Mixin::mut_root_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Mixin", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for Mixin { + fn clear(&mut self) { + self.clear_name(); + self.clear_root(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Mixin { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Mixin { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x19google/protobuf/api.proto\x12\x0fgoogle.protobuf\x1a$google/protob\ + uf/source_context.proto\x1a\x1agoogle/protobuf/type.proto\"\xc1\x02\n\ + \x03Api\x12\x12\n\x04name\x18\x01\x20\x01(\tR\x04name\x121\n\x07methods\ + \x18\x02\x20\x03(\x0b2\x17.google.protobuf.MethodR\x07methods\x121\n\x07\ + options\x18\x03\x20\x03(\x0b2\x17.google.protobuf.OptionR\x07options\x12\ + \x18\n\x07version\x18\x04\x20\x01(\tR\x07version\x12E\n\x0esource_contex\ + t\x18\x05\x20\x01(\x0b2\x1e.google.protobuf.SourceContextR\rsourceContex\ + t\x12.\n\x06mixins\x18\x06\x20\x03(\x0b2\x16.google.protobuf.MixinR\x06m\ + ixins\x12/\n\x06syntax\x18\x07\x20\x01(\x0e2\x17.google.protobuf.SyntaxR\ + \x06syntax\"\xb2\x02\n\x06Method\x12\x12\n\x04name\x18\x01\x20\x01(\tR\ + \x04name\x12(\n\x10request_type_url\x18\x02\x20\x01(\tR\x0erequestTypeUr\ + l\x12+\n\x11request_streaming\x18\x03\x20\x01(\x08R\x10requestStreaming\ + \x12*\n\x11response_type_url\x18\x04\x20\x01(\tR\x0fresponseTypeUrl\x12-\ + \n\x12response_streaming\x18\x05\x20\x01(\x08R\x11responseStreaming\x121\ + \n\x07options\x18\x06\x20\x03(\x0b2\x17.google.protobuf.OptionR\x07optio\ + ns\x12/\n\x06syntax\x18\x07\x20\x01(\x0e2\x17.google.protobuf.SyntaxR\ + \x06syntax\"/\n\x05Mixin\x12\x12\n\x04name\x18\x01\x20\x01(\tR\x04name\ + \x12\x12\n\x04root\x18\x02\x20\x01(\tR\x04rootBH\n\x13com.google.protobu\ + fB\x08ApiProtoP\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownT\ + ypesJ\x92;\n\x07\x12\x05\x1e\0\xc8\x01\x01\n\xcc\x0c\n\x01\x0c\x12\x03\ + \x1e\0\x122\xc1\x0c\x20Protocol\x20Buffers\x20-\x20Google's\x20data\x20i\ + nterchange\x20format\n\x20Copyright\x202008\x20Google\x20Inc.\x20\x20All\ + \x20rights\x20reserved.\n\x20https://developers.google.com/protocol-buff\ + ers/\n\n\x20Redistribution\x20and\x20use\x20in\x20source\x20and\x20binar\ + y\x20forms,\x20with\x20or\x20without\n\x20modification,\x20are\x20permit\ + ted\x20provided\x20that\x20the\x20following\x20conditions\x20are\n\x20me\ + t:\n\n\x20\x20\x20\x20\x20*\x20Redistributions\x20of\x20source\x20code\ + \x20must\x20retain\x20the\x20above\x20copyright\n\x20notice,\x20this\x20\ + list\x20of\x20conditions\x20and\x20the\x20following\x20disclaimer.\n\x20\ + \x20\x20\x20\x20*\x20Redistributions\x20in\x20binary\x20form\x20must\x20\ + reproduce\x20the\x20above\n\x20copyright\x20notice,\x20this\x20list\x20o\ + f\x20conditions\x20and\x20the\x20following\x20disclaimer\n\x20in\x20the\ + \x20documentation\x20and/or\x20other\x20materials\x20provided\x20with\ + \x20the\n\x20distribution.\n\x20\x20\x20\x20\x20*\x20Neither\x20the\x20n\ + ame\x20of\x20Google\x20Inc.\x20nor\x20the\x20names\x20of\x20its\n\x20con\ + tributors\x20may\x20be\x20used\x20to\x20endorse\x20or\x20promote\x20prod\ + ucts\x20derived\x20from\n\x20this\x20software\x20without\x20specific\x20\ + prior\x20written\x20permission.\n\n\x20THIS\x20SOFTWARE\x20IS\x20PROVIDE\ + D\x20BY\x20THE\x20COPYRIGHT\x20HOLDERS\x20AND\x20CONTRIBUTORS\n\x20\"AS\ + \x20IS\"\x20AND\x20ANY\x20EXPRESS\x20OR\x20IMPLIED\x20WARRANTIES,\x20INC\ + LUDING,\x20BUT\x20NOT\n\x20LIMITED\x20TO,\x20THE\x20IMPLIED\x20WARRANTIE\ + S\x20OF\x20MERCHANTABILITY\x20AND\x20FITNESS\x20FOR\n\x20A\x20PARTICULAR\ + \x20PURPOSE\x20ARE\x20DISCLAIMED.\x20IN\x20NO\x20EVENT\x20SHALL\x20THE\ + \x20COPYRIGHT\n\x20OWNER\x20OR\x20CONTRIBUTORS\x20BE\x20LIABLE\x20FOR\ + \x20ANY\x20DIRECT,\x20INDIRECT,\x20INCIDENTAL,\n\x20SPECIAL,\x20EXEMPLAR\ + Y,\x20OR\x20CONSEQUENTIAL\x20DAMAGES\x20(INCLUDING,\x20BUT\x20NOT\n\x20L\ + IMITED\x20TO,\x20PROCUREMENT\x20OF\x20SUBSTITUTE\x20GOODS\x20OR\x20SERVI\ + CES;\x20LOSS\x20OF\x20USE,\n\x20DATA,\x20OR\x20PROFITS;\x20OR\x20BUSINES\ + S\x20INTERRUPTION)\x20HOWEVER\x20CAUSED\x20AND\x20ON\x20ANY\n\x20THEORY\ + \x20OF\x20LIABILITY,\x20WHETHER\x20IN\x20CONTRACT,\x20STRICT\x20LIABILIT\ + Y,\x20OR\x20TORT\n\x20(INCLUDING\x20NEGLIGENCE\x20OR\x20OTHERWISE)\x20AR\ + ISING\x20IN\x20ANY\x20WAY\x20OUT\x20OF\x20THE\x20USE\n\x20OF\x20THIS\x20\ + SOFTWARE,\x20EVEN\x20IF\x20ADVISED\x20OF\x20THE\x20POSSIBILITY\x20OF\x20\ + SUCH\x20DAMAGE.\n\n\x08\n\x01\x02\x12\x03\x20\x08\x17\n\t\n\x02\x03\0\ + \x12\x03\"\x07-\n\t\n\x02\x03\x01\x12\x03#\x07#\n\x08\n\x01\x08\x12\x03%\ + \0;\n\x0b\n\x04\x08\xe7\x07\0\x12\x03%\0;\n\x0c\n\x05\x08\xe7\x07\0\x02\ + \x12\x03%\x07\x17\n\r\n\x06\x08\xe7\x07\0\x02\0\x12\x03%\x07\x17\n\x0e\n\ + \x07\x08\xe7\x07\0\x02\0\x01\x12\x03%\x07\x17\n\x0c\n\x05\x08\xe7\x07\0\ + \x07\x12\x03%\x1a:\n\x08\n\x01\x08\x12\x03&\0,\n\x0b\n\x04\x08\xe7\x07\ + \x01\x12\x03&\0,\n\x0c\n\x05\x08\xe7\x07\x01\x02\x12\x03&\x07\x13\n\r\n\ + \x06\x08\xe7\x07\x01\x02\0\x12\x03&\x07\x13\n\x0e\n\x07\x08\xe7\x07\x01\ + \x02\0\x01\x12\x03&\x07\x13\n\x0c\n\x05\x08\xe7\x07\x01\x07\x12\x03&\x16\ + +\n\x08\n\x01\x08\x12\x03'\0)\n\x0b\n\x04\x08\xe7\x07\x02\x12\x03'\0)\n\ + \x0c\n\x05\x08\xe7\x07\x02\x02\x12\x03'\x07\x1b\n\r\n\x06\x08\xe7\x07\ + \x02\x02\0\x12\x03'\x07\x1b\n\x0e\n\x07\x08\xe7\x07\x02\x02\0\x01\x12\ + \x03'\x07\x1b\n\x0c\n\x05\x08\xe7\x07\x02\x07\x12\x03'\x1e(\n\x08\n\x01\ + \x08\x12\x03(\0\"\n\x0b\n\x04\x08\xe7\x07\x03\x12\x03(\0\"\n\x0c\n\x05\ + \x08\xe7\x07\x03\x02\x12\x03(\x07\x1a\n\r\n\x06\x08\xe7\x07\x03\x02\0\ + \x12\x03(\x07\x1a\n\x0e\n\x07\x08\xe7\x07\x03\x02\0\x01\x12\x03(\x07\x1a\ + \n\x0c\n\x05\x08\xe7\x07\x03\x03\x12\x03(\x1d!\n\x08\n\x01\x08\x12\x03)\ + \0!\n\x0b\n\x04\x08\xe7\x07\x04\x12\x03)\0!\n\x0c\n\x05\x08\xe7\x07\x04\ + \x02\x12\x03)\x07\x18\n\r\n\x06\x08\xe7\x07\x04\x02\0\x12\x03)\x07\x18\n\ + \x0e\n\x07\x08\xe7\x07\x04\x02\0\x01\x12\x03)\x07\x18\n\x0c\n\x05\x08\ + \xe7\x07\x04\x07\x12\x03)\x1b\x20\nM\n\x02\x04\0\x12\x04,\0Y\x01\x1aA\ + \x20Api\x20is\x20a\x20light-weight\x20descriptor\x20for\x20a\x20protocol\ + \x20buffer\x20service.\n\n\n\n\x03\x04\0\x01\x12\x03,\x08\x0b\no\n\x04\ + \x04\0\x02\0\x12\x030\x02\x12\x1ab\x20The\x20fully\x20qualified\x20name\ + \x20of\x20this\x20api,\x20including\x20package\x20name\n\x20followed\x20\ + by\x20the\x20api's\x20simple\x20name.\n\n\r\n\x05\x04\0\x02\0\x04\x12\ + \x040\x02,\r\n\x0c\n\x05\x04\0\x02\0\x05\x12\x030\x02\x08\n\x0c\n\x05\ + \x04\0\x02\0\x01\x12\x030\t\r\n\x0c\n\x05\x04\0\x02\0\x03\x12\x030\x10\ + \x11\n=\n\x04\x04\0\x02\x01\x12\x033\x02\x1e\x1a0\x20The\x20methods\x20o\ + f\x20this\x20api,\x20in\x20unspecified\x20order.\n\n\x0c\n\x05\x04\0\x02\ + \x01\x04\x12\x033\x02\n\n\x0c\n\x05\x04\0\x02\x01\x06\x12\x033\x0b\x11\n\ + \x0c\n\x05\x04\0\x02\x01\x01\x12\x033\x12\x19\n\x0c\n\x05\x04\0\x02\x01\ + \x03\x12\x033\x1c\x1d\n0\n\x04\x04\0\x02\x02\x12\x036\x02\x1e\x1a#\x20An\ + y\x20metadata\x20attached\x20to\x20the\x20API.\n\n\x0c\n\x05\x04\0\x02\ + \x02\x04\x12\x036\x02\n\n\x0c\n\x05\x04\0\x02\x02\x06\x12\x036\x0b\x11\n\ + \x0c\n\x05\x04\0\x02\x02\x01\x12\x036\x12\x19\n\x0c\n\x05\x04\0\x02\x02\ + \x03\x12\x036\x1c\x1d\n\xf2\x07\n\x04\x04\0\x02\x03\x12\x03N\x02\x15\x1a\ + \xe4\x07\x20A\x20version\x20string\x20for\x20this\x20api.\x20If\x20speci\ + fied,\x20must\x20have\x20the\x20form\n\x20`major-version.minor-version`,\ + \x20as\x20in\x20`1.10`.\x20If\x20the\x20minor\x20version\n\x20is\x20omit\ + ted,\x20it\x20defaults\x20to\x20zero.\x20If\x20the\x20entire\x20version\ + \x20field\x20is\n\x20empty,\x20the\x20major\x20version\x20is\x20derived\ + \x20from\x20the\x20package\x20name,\x20as\n\x20outlined\x20below.\x20If\ + \x20the\x20field\x20is\x20not\x20empty,\x20the\x20version\x20in\x20the\n\ + \x20package\x20name\x20will\x20be\x20verified\x20to\x20be\x20consistent\ + \x20with\x20what\x20is\n\x20provided\x20here.\n\n\x20The\x20versioning\ + \x20schema\x20uses\x20[semantic\n\x20versioning](http://semver.org)\x20w\ + here\x20the\x20major\x20version\x20number\n\x20indicates\x20a\x20breakin\ + g\x20change\x20and\x20the\x20minor\x20version\x20an\x20additive,\n\x20no\ + n-breaking\x20change.\x20Both\x20version\x20numbers\x20are\x20signals\ + \x20to\x20users\n\x20what\x20to\x20expect\x20from\x20different\x20versio\ + ns,\x20and\x20should\x20be\x20carefully\n\x20chosen\x20based\x20on\x20th\ + e\x20product\x20plan.\n\n\x20The\x20major\x20version\x20is\x20also\x20re\ + flected\x20in\x20the\x20package\x20name\x20of\x20the\n\x20API,\x20which\ + \x20must\x20end\x20in\x20`v`,\x20as\x20in\n\x20`google.fe\ + ature.v1`.\x20For\x20major\x20versions\x200\x20and\x201,\x20the\x20suffi\ + x\x20can\n\x20be\x20omitted.\x20Zero\x20major\x20versions\x20must\x20onl\ + y\x20be\x20used\x20for\n\x20experimental,\x20none-GA\x20apis.\n\n\n\n\r\ + \n\x05\x04\0\x02\x03\x04\x12\x04N\x026\x1e\n\x0c\n\x05\x04\0\x02\x03\x05\ + \x12\x03N\x02\x08\n\x0c\n\x05\x04\0\x02\x03\x01\x12\x03N\t\x10\n\x0c\n\ + \x05\x04\0\x02\x03\x03\x12\x03N\x13\x14\n[\n\x04\x04\0\x02\x04\x12\x03R\ + \x02#\x1aN\x20Source\x20context\x20for\x20the\x20protocol\x20buffer\x20s\ + ervice\x20represented\x20by\x20this\n\x20message.\n\n\r\n\x05\x04\0\x02\ + \x04\x04\x12\x04R\x02N\x15\n\x0c\n\x05\x04\0\x02\x04\x06\x12\x03R\x02\ + \x0f\n\x0c\n\x05\x04\0\x02\x04\x01\x12\x03R\x10\x1e\n\x0c\n\x05\x04\0\ + \x02\x04\x03\x12\x03R!\"\n,\n\x04\x04\0\x02\x05\x12\x03U\x02\x1c\x1a\x1f\ + \x20Included\x20APIs.\x20See\x20[Mixin][].\n\n\x0c\n\x05\x04\0\x02\x05\ + \x04\x12\x03U\x02\n\n\x0c\n\x05\x04\0\x02\x05\x06\x12\x03U\x0b\x10\n\x0c\ + \n\x05\x04\0\x02\x05\x01\x12\x03U\x11\x17\n\x0c\n\x05\x04\0\x02\x05\x03\ + \x12\x03U\x1a\x1b\n0\n\x04\x04\0\x02\x06\x12\x03X\x02\x14\x1a#\x20The\ + \x20source\x20syntax\x20of\x20the\x20service.\n\n\r\n\x05\x04\0\x02\x06\ + \x04\x12\x04X\x02U\x1c\n\x0c\n\x05\x04\0\x02\x06\x06\x12\x03X\x02\x08\n\ + \x0c\n\x05\x04\0\x02\x06\x01\x12\x03X\t\x0f\n\x0c\n\x05\x04\0\x02\x06\ + \x03\x12\x03X\x12\x13\n3\n\x02\x04\x01\x12\x04\\\0r\x01\x1a'\x20Method\ + \x20represents\x20a\x20method\x20of\x20an\x20api.\n\n\n\n\x03\x04\x01\ + \x01\x12\x03\\\x08\x0e\n.\n\x04\x04\x01\x02\0\x12\x03_\x02\x12\x1a!\x20T\ + he\x20simple\x20name\x20of\x20this\x20method.\n\n\r\n\x05\x04\x01\x02\0\ + \x04\x12\x04_\x02\\\x10\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03_\x02\x08\n\ + \x0c\n\x05\x04\x01\x02\0\x01\x12\x03_\t\r\n\x0c\n\x05\x04\x01\x02\0\x03\ + \x12\x03_\x10\x11\n/\n\x04\x04\x01\x02\x01\x12\x03b\x02\x1e\x1a\"\x20A\ + \x20URL\x20of\x20the\x20input\x20message\x20type.\n\n\r\n\x05\x04\x01\ + \x02\x01\x04\x12\x04b\x02_\x12\n\x0c\n\x05\x04\x01\x02\x01\x05\x12\x03b\ + \x02\x08\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03b\t\x19\n\x0c\n\x05\x04\ + \x01\x02\x01\x03\x12\x03b\x1c\x1d\n0\n\x04\x04\x01\x02\x02\x12\x03e\x02\ + \x1d\x1a#\x20If\x20true,\x20the\x20request\x20is\x20streamed.\n\n\r\n\ + \x05\x04\x01\x02\x02\x04\x12\x04e\x02b\x1e\n\x0c\n\x05\x04\x01\x02\x02\ + \x05\x12\x03e\x02\x06\n\x0c\n\x05\x04\x01\x02\x02\x01\x12\x03e\x07\x18\n\ + \x0c\n\x05\x04\x01\x02\x02\x03\x12\x03e\x1b\x1c\n2\n\x04\x04\x01\x02\x03\ + \x12\x03h\x02\x1f\x1a%\x20The\x20URL\x20of\x20the\x20output\x20message\ + \x20type.\n\n\r\n\x05\x04\x01\x02\x03\x04\x12\x04h\x02e\x1d\n\x0c\n\x05\ + \x04\x01\x02\x03\x05\x12\x03h\x02\x08\n\x0c\n\x05\x04\x01\x02\x03\x01\ + \x12\x03h\t\x1a\n\x0c\n\x05\x04\x01\x02\x03\x03\x12\x03h\x1d\x1e\n1\n\ + \x04\x04\x01\x02\x04\x12\x03k\x02\x1e\x1a$\x20If\x20true,\x20the\x20resp\ + onse\x20is\x20streamed.\n\n\r\n\x05\x04\x01\x02\x04\x04\x12\x04k\x02h\ + \x1f\n\x0c\n\x05\x04\x01\x02\x04\x05\x12\x03k\x02\x06\n\x0c\n\x05\x04\ + \x01\x02\x04\x01\x12\x03k\x07\x19\n\x0c\n\x05\x04\x01\x02\x04\x03\x12\ + \x03k\x1c\x1d\n3\n\x04\x04\x01\x02\x05\x12\x03n\x02\x1e\x1a&\x20Any\x20m\ + etadata\x20attached\x20to\x20the\x20method.\n\n\x0c\n\x05\x04\x01\x02\ + \x05\x04\x12\x03n\x02\n\n\x0c\n\x05\x04\x01\x02\x05\x06\x12\x03n\x0b\x11\ + \n\x0c\n\x05\x04\x01\x02\x05\x01\x12\x03n\x12\x19\n\x0c\n\x05\x04\x01\ + \x02\x05\x03\x12\x03n\x1c\x1d\n0\n\x04\x04\x01\x02\x06\x12\x03q\x02\x14\ + \x1a#\x20The\x20source\x20syntax\x20of\x20this\x20method.\n\n\r\n\x05\ + \x04\x01\x02\x06\x04\x12\x04q\x02n\x1e\n\x0c\n\x05\x04\x01\x02\x06\x06\ + \x12\x03q\x02\x08\n\x0c\n\x05\x04\x01\x02\x06\x01\x12\x03q\t\x0f\n\x0c\n\ + \x05\x04\x01\x02\x06\x03\x12\x03q\x12\x13\n\xa4\x13\n\x02\x04\x02\x12\ + \x06\xc1\x01\0\xc8\x01\x01\x1a\x95\x13\x20Declares\x20an\x20API\x20to\ + \x20be\x20included\x20in\x20this\x20API.\x20The\x20including\x20API\x20m\ + ust\n\x20redeclare\x20all\x20the\x20methods\x20from\x20the\x20included\ + \x20API,\x20but\x20documentation\n\x20and\x20options\x20are\x20inherited\ + \x20as\x20follows:\n\n\x20-\x20If\x20after\x20comment\x20and\x20whitespa\ + ce\x20stripping,\x20the\x20documentation\n\x20\x20\x20string\x20of\x20th\ + e\x20redeclared\x20method\x20is\x20empty,\x20it\x20will\x20be\x20inherit\ + ed\n\x20\x20\x20from\x20the\x20original\x20method.\n\n\x20-\x20Each\x20a\ + nnotation\x20belonging\x20to\x20the\x20service\x20config\x20(http,\n\x20\ + \x20\x20visibility)\x20which\x20is\x20not\x20set\x20in\x20the\x20redecla\ + red\x20method\x20will\x20be\n\x20\x20\x20inherited.\n\n\x20-\x20If\x20an\ + \x20http\x20annotation\x20is\x20inherited,\x20the\x20path\x20pattern\x20\ + will\x20be\n\x20\x20\x20modified\x20as\x20follows.\x20Any\x20version\x20\ + prefix\x20will\x20be\x20replaced\x20by\x20the\n\x20\x20\x20version\x20of\ + \x20the\x20including\x20API\x20plus\x20the\x20[root][]\x20path\x20if\x20\ + specified.\n\n\x20Example\x20of\x20a\x20simple\x20mixin:\n\n\x20\x20\x20\ + \x20\x20package\x20google.acl.v1;\n\x20\x20\x20\x20\x20service\x20Access\ + Control\x20{\n\x20\x20\x20\x20\x20\x20\x20//\x20Get\x20the\x20underlying\ + \x20ACL\x20object.\n\x20\x20\x20\x20\x20\x20\x20rpc\x20GetAcl(GetAclRequ\ + est)\x20returns\x20(Acl)\x20{\n\x20\x20\x20\x20\x20\x20\x20\x20\x20optio\ + n\x20(google.api.http).get\x20=\x20\"/v1/{resource=**}:getAcl\";\n\x20\ + \x20\x20\x20\x20\x20\x20}\n\x20\x20\x20\x20\x20}\n\n\x20\x20\x20\x20\x20\ + package\x20google.storage.v2;\n\x20\x20\x20\x20\x20service\x20Storage\ + \x20{\n\x20\x20\x20\x20\x20\x20\x20rpc\x20GetAcl(GetAclRequest)\x20retur\ + ns\x20(Acl);\n\n\x20\x20\x20\x20\x20\x20\x20//\x20Get\x20a\x20data\x20re\ + cord.\n\x20\x20\x20\x20\x20\x20\x20rpc\x20GetData(GetDataRequest)\x20ret\ + urns\x20(Data)\x20{\n\x20\x20\x20\x20\x20\x20\x20\x20\x20option\x20(goog\ + le.api.http).get\x20=\x20\"/v2/{resource=**}\";\n\x20\x20\x20\x20\x20\ + \x20\x20}\n\x20\x20\x20\x20\x20}\n\n\x20Example\x20of\x20a\x20mixin\x20c\ + onfiguration:\n\n\x20\x20\x20\x20\x20apis:\n\x20\x20\x20\x20\x20-\x20nam\ + e:\x20google.storage.v2.Storage\n\x20\x20\x20\x20\x20\x20\x20mixins:\n\ + \x20\x20\x20\x20\x20\x20\x20-\x20name:\x20google.acl.v1.AccessControl\n\ + \n\x20The\x20mixin\x20construct\x20implies\x20that\x20all\x20methods\x20\ + in\x20`AccessControl`\x20are\n\x20also\x20declared\x20with\x20same\x20na\ + me\x20and\x20request/response\x20types\x20in\n\x20`Storage`.\x20A\x20doc\ + umentation\x20generator\x20or\x20annotation\x20processor\x20will\n\x20se\ + e\x20the\x20effective\x20`Storage.GetAcl`\x20method\x20after\x20inhertin\ + g\n\x20documentation\x20and\x20annotations\x20as\x20follows:\n\n\x20\x20\ + \x20\x20\x20service\x20Storage\x20{\n\x20\x20\x20\x20\x20\x20\x20//\x20G\ + et\x20the\x20underlying\x20ACL\x20object.\n\x20\x20\x20\x20\x20\x20\x20r\ + pc\x20GetAcl(GetAclRequest)\x20returns\x20(Acl)\x20{\n\x20\x20\x20\x20\ + \x20\x20\x20\x20\x20option\x20(google.api.http).get\x20=\x20\"/v2/{resou\ + rce=**}:getAcl\";\n\x20\x20\x20\x20\x20\x20\x20}\n\x20\x20\x20\x20\x20\ + \x20\x20...\n\x20\x20\x20\x20\x20}\n\n\x20Note\x20how\x20the\x20version\ + \x20in\x20the\x20path\x20pattern\x20changed\x20from\x20`v1`\x20to\x20`v2\ + `.\n\n\x20If\x20the\x20`root`\x20field\x20in\x20the\x20mixin\x20is\x20sp\ + ecified,\x20it\x20should\x20be\x20a\n\x20relative\x20path\x20under\x20wh\ + ich\x20inherited\x20HTTP\x20paths\x20are\x20placed.\x20Example:\n\n\x20\ + \x20\x20\x20\x20apis:\n\x20\x20\x20\x20\x20-\x20name:\x20google.storage.\ + v2.Storage\n\x20\x20\x20\x20\x20\x20\x20mixins:\n\x20\x20\x20\x20\x20\ + \x20\x20-\x20name:\x20google.acl.v1.AccessControl\n\x20\x20\x20\x20\x20\ + \x20\x20\x20\x20root:\x20acls\n\n\x20This\x20implies\x20the\x20following\ + \x20inherited\x20HTTP\x20annotation:\n\n\x20\x20\x20\x20\x20service\x20S\ + torage\x20{\n\x20\x20\x20\x20\x20\x20\x20//\x20Get\x20the\x20underlying\ + \x20ACL\x20object.\n\x20\x20\x20\x20\x20\x20\x20rpc\x20GetAcl(GetAclRequ\ + est)\x20returns\x20(Acl)\x20{\n\x20\x20\x20\x20\x20\x20\x20\x20\x20optio\ + n\x20(google.api.http).get\x20=\x20\"/v2/acls/{resource=**}:getAcl\";\n\ + \x20\x20\x20\x20\x20\x20\x20}\n\x20\x20\x20\x20\x20\x20\x20...\n\x20\x20\ + \x20\x20\x20}\n\n\x0b\n\x03\x04\x02\x01\x12\x04\xc1\x01\x08\r\nF\n\x04\ + \x04\x02\x02\0\x12\x04\xc3\x01\x02\x12\x1a8\x20The\x20fully\x20qualified\ + \x20name\x20of\x20the\x20API\x20which\x20is\x20included.\n\n\x0f\n\x05\ + \x04\x02\x02\0\x04\x12\x06\xc3\x01\x02\xc1\x01\x0f\n\r\n\x05\x04\x02\x02\ + \0\x05\x12\x04\xc3\x01\x02\x08\n\r\n\x05\x04\x02\x02\0\x01\x12\x04\xc3\ + \x01\t\r\n\r\n\x05\x04\x02\x02\0\x03\x12\x04\xc3\x01\x10\x11\n[\n\x04\ + \x04\x02\x02\x01\x12\x04\xc7\x01\x02\x12\x1aM\x20If\x20non-empty\x20spec\ + ifies\x20a\x20path\x20under\x20which\x20inherited\x20HTTP\x20paths\n\x20\ + are\x20rooted.\n\n\x0f\n\x05\x04\x02\x02\x01\x04\x12\x06\xc7\x01\x02\xc3\ + \x01\x12\n\r\n\x05\x04\x02\x02\x01\x05\x12\x04\xc7\x01\x02\x08\n\r\n\x05\ + \x04\x02\x02\x01\x01\x12\x04\xc7\x01\t\r\n\r\n\x05\x04\x02\x02\x01\x03\ + \x12\x04\xc7\x01\x10\x11b\x06proto3\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/third_party/protobuf/src/well_known_types/duration.rs b/third_party/protobuf/src/well_known_types/duration.rs new file mode 100644 index 000000000..f58504d2f --- /dev/null +++ b/third_party/protobuf/src/well_known_types/duration.rs @@ -0,0 +1,377 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +use std::boxed::Box; + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +#[derive(PartialEq,Clone,Default)] +pub struct Duration { + // message fields + pub seconds: i64, + pub nanos: i32, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for Duration {} + +impl Duration { + pub fn new() -> Duration { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static Duration { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Duration, + }; + unsafe { + instance.get(Duration::new) + } + } + + // int64 seconds = 1; + + pub fn clear_seconds(&mut self) { + self.seconds = 0; + } + + // Param is passed by value, moved + pub fn set_seconds(&mut self, v: i64) { + self.seconds = v; + } + + pub fn get_seconds(&self) -> i64 { + self.seconds + } + + fn get_seconds_for_reflect(&self) -> &i64 { + &self.seconds + } + + fn mut_seconds_for_reflect(&mut self) -> &mut i64 { + &mut self.seconds + } + + // int32 nanos = 2; + + pub fn clear_nanos(&mut self) { + self.nanos = 0; + } + + // Param is passed by value, moved + pub fn set_nanos(&mut self, v: i32) { + self.nanos = v; + } + + pub fn get_nanos(&self) -> i32 { + self.nanos + } + + fn get_nanos_for_reflect(&self) -> &i32 { + &self.nanos + } + + fn mut_nanos_for_reflect(&mut self) -> &mut i32 { + &mut self.nanos + } +} + +impl ::protobuf::Message for Duration { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int64()?; + self.seconds = tmp; + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int32()?; + self.nanos = tmp; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if self.seconds != 0 { + my_size += ::protobuf::rt::value_size(1, self.seconds, ::protobuf::wire_format::WireTypeVarint); + } + if self.nanos != 0 { + my_size += ::protobuf::rt::value_size(2, self.nanos, ::protobuf::wire_format::WireTypeVarint); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if self.seconds != 0 { + os.write_int64(1, self.seconds)?; + } + if self.nanos != 0 { + os.write_int32(2, self.nanos)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for Duration { + fn new() -> Duration { + Duration::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( + "seconds", + Duration::get_seconds_for_reflect, + Duration::mut_seconds_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "nanos", + Duration::get_nanos_for_reflect, + Duration::mut_nanos_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Duration", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for Duration { + fn clear(&mut self) { + self.clear_seconds(); + self.clear_nanos(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Duration { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Duration { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x1egoogle/protobuf/duration.proto\x12\x0fgoogle.protobuf\":\n\x08Dura\ + tion\x12\x18\n\x07seconds\x18\x01\x20\x01(\x03R\x07seconds\x12\x14\n\x05\ + nanos\x18\x02\x20\x01(\x05R\x05nanosB|\n\x13com.google.protobufB\rDurati\ + onProtoP\x01Z*github.com/golang/protobuf/ptypes/duration\xf8\x01\x01\xa2\ + \x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesJ\xaa\"\n\x06\x12\ + \x04\x1e\0g\x01\n\xcc\x0c\n\x01\x0c\x12\x03\x1e\0\x122\xc1\x0c\x20Protoc\ + ol\x20Buffers\x20-\x20Google's\x20data\x20interchange\x20format\n\x20Cop\ + yright\x202008\x20Google\x20Inc.\x20\x20All\x20rights\x20reserved.\n\x20\ + https://developers.google.com/protocol-buffers/\n\n\x20Redistribution\ + \x20and\x20use\x20in\x20source\x20and\x20binary\x20forms,\x20with\x20or\ + \x20without\n\x20modification,\x20are\x20permitted\x20provided\x20that\ + \x20the\x20following\x20conditions\x20are\n\x20met:\n\n\x20\x20\x20\x20\ + \x20*\x20Redistributions\x20of\x20source\x20code\x20must\x20retain\x20th\ + e\x20above\x20copyright\n\x20notice,\x20this\x20list\x20of\x20conditions\ + \x20and\x20the\x20following\x20disclaimer.\n\x20\x20\x20\x20\x20*\x20Red\ + istributions\x20in\x20binary\x20form\x20must\x20reproduce\x20the\x20abov\ + e\n\x20copyright\x20notice,\x20this\x20list\x20of\x20conditions\x20and\ + \x20the\x20following\x20disclaimer\n\x20in\x20the\x20documentation\x20an\ + d/or\x20other\x20materials\x20provided\x20with\x20the\n\x20distribution.\ + \n\x20\x20\x20\x20\x20*\x20Neither\x20the\x20name\x20of\x20Google\x20Inc\ + .\x20nor\x20the\x20names\x20of\x20its\n\x20contributors\x20may\x20be\x20\ + used\x20to\x20endorse\x20or\x20promote\x20products\x20derived\x20from\n\ + \x20this\x20software\x20without\x20specific\x20prior\x20written\x20permi\ + ssion.\n\n\x20THIS\x20SOFTWARE\x20IS\x20PROVIDED\x20BY\x20THE\x20COPYRIG\ + HT\x20HOLDERS\x20AND\x20CONTRIBUTORS\n\x20\"AS\x20IS\"\x20AND\x20ANY\x20\ + EXPRESS\x20OR\x20IMPLIED\x20WARRANTIES,\x20INCLUDING,\x20BUT\x20NOT\n\ + \x20LIMITED\x20TO,\x20THE\x20IMPLIED\x20WARRANTIES\x20OF\x20MERCHANTABIL\ + ITY\x20AND\x20FITNESS\x20FOR\n\x20A\x20PARTICULAR\x20PURPOSE\x20ARE\x20D\ + ISCLAIMED.\x20IN\x20NO\x20EVENT\x20SHALL\x20THE\x20COPYRIGHT\n\x20OWNER\ + \x20OR\x20CONTRIBUTORS\x20BE\x20LIABLE\x20FOR\x20ANY\x20DIRECT,\x20INDIR\ + ECT,\x20INCIDENTAL,\n\x20SPECIAL,\x20EXEMPLARY,\x20OR\x20CONSEQUENTIAL\ + \x20DAMAGES\x20(INCLUDING,\x20BUT\x20NOT\n\x20LIMITED\x20TO,\x20PROCUREM\ + ENT\x20OF\x20SUBSTITUTE\x20GOODS\x20OR\x20SERVICES;\x20LOSS\x20OF\x20USE\ + ,\n\x20DATA,\x20OR\x20PROFITS;\x20OR\x20BUSINESS\x20INTERRUPTION)\x20HOW\ + EVER\x20CAUSED\x20AND\x20ON\x20ANY\n\x20THEORY\x20OF\x20LIABILITY,\x20WH\ + ETHER\x20IN\x20CONTRACT,\x20STRICT\x20LIABILITY,\x20OR\x20TORT\n\x20(INC\ + LUDING\x20NEGLIGENCE\x20OR\x20OTHERWISE)\x20ARISING\x20IN\x20ANY\x20WAY\ + \x20OUT\x20OF\x20THE\x20USE\n\x20OF\x20THIS\x20SOFTWARE,\x20EVEN\x20IF\ + \x20ADVISED\x20OF\x20THE\x20POSSIBILITY\x20OF\x20SUCH\x20DAMAGE.\n\n\x08\ + \n\x01\x02\x12\x03\x20\x08\x17\n\x08\n\x01\x08\x12\x03\"\0;\n\x0b\n\x04\ + \x08\xe7\x07\0\x12\x03\"\0;\n\x0c\n\x05\x08\xe7\x07\0\x02\x12\x03\"\x07\ + \x17\n\r\n\x06\x08\xe7\x07\0\x02\0\x12\x03\"\x07\x17\n\x0e\n\x07\x08\xe7\ + \x07\0\x02\0\x01\x12\x03\"\x07\x17\n\x0c\n\x05\x08\xe7\x07\0\x07\x12\x03\ + \"\x1a:\n\x08\n\x01\x08\x12\x03#\0\x1f\n\x0b\n\x04\x08\xe7\x07\x01\x12\ + \x03#\0\x1f\n\x0c\n\x05\x08\xe7\x07\x01\x02\x12\x03#\x07\x17\n\r\n\x06\ + \x08\xe7\x07\x01\x02\0\x12\x03#\x07\x17\n\x0e\n\x07\x08\xe7\x07\x01\x02\ + \0\x01\x12\x03#\x07\x17\n\x0c\n\x05\x08\xe7\x07\x01\x03\x12\x03#\x1a\x1e\ + \n\x08\n\x01\x08\x12\x03$\0A\n\x0b\n\x04\x08\xe7\x07\x02\x12\x03$\0A\n\ + \x0c\n\x05\x08\xe7\x07\x02\x02\x12\x03$\x07\x11\n\r\n\x06\x08\xe7\x07\ + \x02\x02\0\x12\x03$\x07\x11\n\x0e\n\x07\x08\xe7\x07\x02\x02\0\x01\x12\ + \x03$\x07\x11\n\x0c\n\x05\x08\xe7\x07\x02\x07\x12\x03$\x14@\n\x08\n\x01\ + \x08\x12\x03%\0,\n\x0b\n\x04\x08\xe7\x07\x03\x12\x03%\0,\n\x0c\n\x05\x08\ + \xe7\x07\x03\x02\x12\x03%\x07\x13\n\r\n\x06\x08\xe7\x07\x03\x02\0\x12\ + \x03%\x07\x13\n\x0e\n\x07\x08\xe7\x07\x03\x02\0\x01\x12\x03%\x07\x13\n\ + \x0c\n\x05\x08\xe7\x07\x03\x07\x12\x03%\x16+\n\x08\n\x01\x08\x12\x03&\0.\ + \n\x0b\n\x04\x08\xe7\x07\x04\x12\x03&\0.\n\x0c\n\x05\x08\xe7\x07\x04\x02\ + \x12\x03&\x07\x1b\n\r\n\x06\x08\xe7\x07\x04\x02\0\x12\x03&\x07\x1b\n\x0e\ + \n\x07\x08\xe7\x07\x04\x02\0\x01\x12\x03&\x07\x1b\n\x0c\n\x05\x08\xe7\ + \x07\x04\x07\x12\x03&\x1e-\n\x08\n\x01\x08\x12\x03'\0\"\n\x0b\n\x04\x08\ + \xe7\x07\x05\x12\x03'\0\"\n\x0c\n\x05\x08\xe7\x07\x05\x02\x12\x03'\x07\ + \x1a\n\r\n\x06\x08\xe7\x07\x05\x02\0\x12\x03'\x07\x1a\n\x0e\n\x07\x08\ + \xe7\x07\x05\x02\0\x01\x12\x03'\x07\x1a\n\x0c\n\x05\x08\xe7\x07\x05\x03\ + \x12\x03'\x1d!\n\x08\n\x01\x08\x12\x03(\0!\n\x0b\n\x04\x08\xe7\x07\x06\ + \x12\x03(\0!\n\x0c\n\x05\x08\xe7\x07\x06\x02\x12\x03(\x07\x18\n\r\n\x06\ + \x08\xe7\x07\x06\x02\0\x12\x03(\x07\x18\n\x0e\n\x07\x08\xe7\x07\x06\x02\ + \0\x01\x12\x03(\x07\x18\n\x0c\n\x05\x08\xe7\x07\x06\x07\x12\x03(\x1b\x20\ + \n\x92\x0c\n\x02\x04\0\x12\x04Z\0g\x01\x1a\x85\x0c\x20A\x20Duration\x20r\ + epresents\x20a\x20signed,\x20fixed-length\x20span\x20of\x20time\x20repre\ + sented\n\x20as\x20a\x20count\x20of\x20seconds\x20and\x20fractions\x20of\ + \x20seconds\x20at\x20nanosecond\n\x20resolution.\x20It\x20is\x20independ\ + ent\x20of\x20any\x20calendar\x20and\x20concepts\x20like\x20\"day\"\n\x20\ + or\x20\"month\".\x20It\x20is\x20related\x20to\x20Timestamp\x20in\x20that\ + \x20the\x20difference\x20between\n\x20two\x20Timestamp\x20values\x20is\ + \x20a\x20Duration\x20and\x20it\x20can\x20be\x20added\x20or\x20subtracted\ + \n\x20from\x20a\x20Timestamp.\x20Range\x20is\x20approximately\x20+-10,00\ + 0\x20years.\n\n\x20Example\x201:\x20Compute\x20Duration\x20from\x20two\ + \x20Timestamps\x20in\x20pseudo\x20code.\n\n\x20\x20\x20\x20\x20Timestamp\ + \x20start\x20=\x20...;\n\x20\x20\x20\x20\x20Timestamp\x20end\x20=\x20...\ + ;\n\x20\x20\x20\x20\x20Duration\x20duration\x20=\x20...;\n\n\x20\x20\x20\ + \x20\x20duration.seconds\x20=\x20end.seconds\x20-\x20start.seconds;\n\ + \x20\x20\x20\x20\x20duration.nanos\x20=\x20end.nanos\x20-\x20start.nanos\ + ;\n\n\x20\x20\x20\x20\x20if\x20(duration.seconds\x20<\x200\x20&&\x20dura\ + tion.nanos\x20>\x200)\x20{\n\x20\x20\x20\x20\x20\x20\x20duration.seconds\ + \x20+=\x201;\n\x20\x20\x20\x20\x20\x20\x20duration.nanos\x20-=\x20100000\ + 0000;\n\x20\x20\x20\x20\x20}\x20else\x20if\x20(durations.seconds\x20>\ + \x200\x20&&\x20duration.nanos\x20<\x200)\x20{\n\x20\x20\x20\x20\x20\x20\ + \x20duration.seconds\x20-=\x201;\n\x20\x20\x20\x20\x20\x20\x20duration.n\ + anos\x20+=\x201000000000;\n\x20\x20\x20\x20\x20}\n\n\x20Example\x202:\ + \x20Compute\x20Timestamp\x20from\x20Timestamp\x20+\x20Duration\x20in\x20\ + pseudo\x20code.\n\n\x20\x20\x20\x20\x20Timestamp\x20start\x20=\x20...;\n\ + \x20\x20\x20\x20\x20Duration\x20duration\x20=\x20...;\n\x20\x20\x20\x20\ + \x20Timestamp\x20end\x20=\x20...;\n\n\x20\x20\x20\x20\x20end.seconds\x20\ + =\x20start.seconds\x20+\x20duration.seconds;\n\x20\x20\x20\x20\x20end.na\ + nos\x20=\x20start.nanos\x20+\x20duration.nanos;\n\n\x20\x20\x20\x20\x20i\ + f\x20(end.nanos\x20<\x200)\x20{\n\x20\x20\x20\x20\x20\x20\x20end.seconds\ + \x20-=\x201;\n\x20\x20\x20\x20\x20\x20\x20end.nanos\x20+=\x201000000000;\ + \n\x20\x20\x20\x20\x20}\x20else\x20if\x20(end.nanos\x20>=\x201000000000)\ + \x20{\n\x20\x20\x20\x20\x20\x20\x20end.seconds\x20+=\x201;\n\x20\x20\x20\ + \x20\x20\x20\x20end.nanos\x20-=\x201000000000;\n\x20\x20\x20\x20\x20}\n\ + \n\x20Example\x203:\x20Compute\x20Duration\x20from\x20datetime.timedelta\ + \x20in\x20Python.\n\n\x20\x20\x20\x20\x20td\x20=\x20datetime.timedelta(d\ + ays=3,\x20minutes=10)\n\x20\x20\x20\x20\x20duration\x20=\x20Duration()\n\ + \x20\x20\x20\x20\x20duration.FromTimedelta(td)\n\n\n\n\n\n\x03\x04\0\x01\ + \x12\x03Z\x08\x10\np\n\x04\x04\0\x02\0\x12\x03^\x02\x14\x1ac\x20Signed\ + \x20seconds\x20of\x20the\x20span\x20of\x20time.\x20Must\x20be\x20from\ + \x20-315,576,000,000\n\x20to\x20+315,576,000,000\x20inclusive.\n\n\r\n\ + \x05\x04\0\x02\0\x04\x12\x04^\x02Z\x12\n\x0c\n\x05\x04\0\x02\0\x05\x12\ + \x03^\x02\x07\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03^\x08\x0f\n\x0c\n\x05\ + \x04\0\x02\0\x03\x12\x03^\x12\x13\n\x83\x03\n\x04\x04\0\x02\x01\x12\x03f\ + \x02\x12\x1a\xf5\x02\x20Signed\x20fractions\x20of\x20a\x20second\x20at\ + \x20nanosecond\x20resolution\x20of\x20the\x20span\n\x20of\x20time.\x20Du\ + rations\x20less\x20than\x20one\x20second\x20are\x20represented\x20with\ + \x20a\x200\n\x20`seconds`\x20field\x20and\x20a\x20positive\x20or\x20nega\ + tive\x20`nanos`\x20field.\x20For\x20durations\n\x20of\x20one\x20second\ + \x20or\x20more,\x20a\x20non-zero\x20value\x20for\x20the\x20`nanos`\x20fi\ + eld\x20must\x20be\n\x20of\x20the\x20same\x20sign\x20as\x20the\x20`second\ + s`\x20field.\x20Must\x20be\x20from\x20-999,999,999\n\x20to\x20+999,999,9\ + 99\x20inclusive.\n\n\r\n\x05\x04\0\x02\x01\x04\x12\x04f\x02^\x14\n\x0c\n\ + \x05\x04\0\x02\x01\x05\x12\x03f\x02\x07\n\x0c\n\x05\x04\0\x02\x01\x01\ + \x12\x03f\x08\r\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03f\x10\x11b\x06proto\ + 3\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/third_party/protobuf/src/well_known_types/empty.rs b/third_party/protobuf/src/well_known_types/empty.rs new file mode 100644 index 000000000..4cab62aa5 --- /dev/null +++ b/third_party/protobuf/src/well_known_types/empty.rs @@ -0,0 +1,244 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +use std::boxed::Box; + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +#[derive(PartialEq,Clone,Default)] +pub struct Empty { + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for Empty {} + +impl Empty { + pub fn new() -> Empty { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static Empty { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Empty, + }; + unsafe { + instance.get(Empty::new) + } + } +} + +impl ::protobuf::Message for Empty { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for Empty { + fn new() -> Empty { + Empty::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let fields = ::std::vec::Vec::new(); + ::protobuf::reflect::MessageDescriptor::new::( + "Empty", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for Empty { + fn clear(&mut self) { + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Empty { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Empty { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x1bgoogle/protobuf/empty.proto\x12\x0fgoogle.protobuf\"\x07\n\x05Empt\ + yBv\n\x13com.google.protobufB\nEmptyProtoP\x01Z'github.com/golang/protob\ + uf/ptypes/empty\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.We\ + llKnownTypesJ\xa9\x14\n\x06\x12\x04\x1e\03\x10\n\xcc\x0c\n\x01\x0c\x12\ + \x03\x1e\0\x122\xc1\x0c\x20Protocol\x20Buffers\x20-\x20Google's\x20data\ + \x20interchange\x20format\n\x20Copyright\x202008\x20Google\x20Inc.\x20\ + \x20All\x20rights\x20reserved.\n\x20https://developers.google.com/protoc\ + ol-buffers/\n\n\x20Redistribution\x20and\x20use\x20in\x20source\x20and\ + \x20binary\x20forms,\x20with\x20or\x20without\n\x20modification,\x20are\ + \x20permitted\x20provided\x20that\x20the\x20following\x20conditions\x20a\ + re\n\x20met:\n\n\x20\x20\x20\x20\x20*\x20Redistributions\x20of\x20source\ + \x20code\x20must\x20retain\x20the\x20above\x20copyright\n\x20notice,\x20\ + this\x20list\x20of\x20conditions\x20and\x20the\x20following\x20disclaime\ + r.\n\x20\x20\x20\x20\x20*\x20Redistributions\x20in\x20binary\x20form\x20\ + must\x20reproduce\x20the\x20above\n\x20copyright\x20notice,\x20this\x20l\ + ist\x20of\x20conditions\x20and\x20the\x20following\x20disclaimer\n\x20in\ + \x20the\x20documentation\x20and/or\x20other\x20materials\x20provided\x20\ + with\x20the\n\x20distribution.\n\x20\x20\x20\x20\x20*\x20Neither\x20the\ + \x20name\x20of\x20Google\x20Inc.\x20nor\x20the\x20names\x20of\x20its\n\ + \x20contributors\x20may\x20be\x20used\x20to\x20endorse\x20or\x20promote\ + \x20products\x20derived\x20from\n\x20this\x20software\x20without\x20spec\ + ific\x20prior\x20written\x20permission.\n\n\x20THIS\x20SOFTWARE\x20IS\ + \x20PROVIDED\x20BY\x20THE\x20COPYRIGHT\x20HOLDERS\x20AND\x20CONTRIBUTORS\ + \n\x20\"AS\x20IS\"\x20AND\x20ANY\x20EXPRESS\x20OR\x20IMPLIED\x20WARRANTI\ + ES,\x20INCLUDING,\x20BUT\x20NOT\n\x20LIMITED\x20TO,\x20THE\x20IMPLIED\ + \x20WARRANTIES\x20OF\x20MERCHANTABILITY\x20AND\x20FITNESS\x20FOR\n\x20A\ + \x20PARTICULAR\x20PURPOSE\x20ARE\x20DISCLAIMED.\x20IN\x20NO\x20EVENT\x20\ + SHALL\x20THE\x20COPYRIGHT\n\x20OWNER\x20OR\x20CONTRIBUTORS\x20BE\x20LIAB\ + LE\x20FOR\x20ANY\x20DIRECT,\x20INDIRECT,\x20INCIDENTAL,\n\x20SPECIAL,\ + \x20EXEMPLARY,\x20OR\x20CONSEQUENTIAL\x20DAMAGES\x20(INCLUDING,\x20BUT\ + \x20NOT\n\x20LIMITED\x20TO,\x20PROCUREMENT\x20OF\x20SUBSTITUTE\x20GOODS\ + \x20OR\x20SERVICES;\x20LOSS\x20OF\x20USE,\n\x20DATA,\x20OR\x20PROFITS;\ + \x20OR\x20BUSINESS\x20INTERRUPTION)\x20HOWEVER\x20CAUSED\x20AND\x20ON\ + \x20ANY\n\x20THEORY\x20OF\x20LIABILITY,\x20WHETHER\x20IN\x20CONTRACT,\ + \x20STRICT\x20LIABILITY,\x20OR\x20TORT\n\x20(INCLUDING\x20NEGLIGENCE\x20\ + OR\x20OTHERWISE)\x20ARISING\x20IN\x20ANY\x20WAY\x20OUT\x20OF\x20THE\x20U\ + SE\n\x20OF\x20THIS\x20SOFTWARE,\x20EVEN\x20IF\x20ADVISED\x20OF\x20THE\ + \x20POSSIBILITY\x20OF\x20SUCH\x20DAMAGE.\n\n\x08\n\x01\x02\x12\x03\x20\ + \x08\x17\n\x08\n\x01\x08\x12\x03\"\0;\n\x0b\n\x04\x08\xe7\x07\0\x12\x03\ + \"\0;\n\x0c\n\x05\x08\xe7\x07\0\x02\x12\x03\"\x07\x17\n\r\n\x06\x08\xe7\ + \x07\0\x02\0\x12\x03\"\x07\x17\n\x0e\n\x07\x08\xe7\x07\0\x02\0\x01\x12\ + \x03\"\x07\x17\n\x0c\n\x05\x08\xe7\x07\0\x07\x12\x03\"\x1a:\n\x08\n\x01\ + \x08\x12\x03#\0>\n\x0b\n\x04\x08\xe7\x07\x01\x12\x03#\0>\n\x0c\n\x05\x08\ + \xe7\x07\x01\x02\x12\x03#\x07\x11\n\r\n\x06\x08\xe7\x07\x01\x02\0\x12\ + \x03#\x07\x11\n\x0e\n\x07\x08\xe7\x07\x01\x02\0\x01\x12\x03#\x07\x11\n\ + \x0c\n\x05\x08\xe7\x07\x01\x07\x12\x03#\x14=\n\x08\n\x01\x08\x12\x03$\0,\ + \n\x0b\n\x04\x08\xe7\x07\x02\x12\x03$\0,\n\x0c\n\x05\x08\xe7\x07\x02\x02\ + \x12\x03$\x07\x13\n\r\n\x06\x08\xe7\x07\x02\x02\0\x12\x03$\x07\x13\n\x0e\ + \n\x07\x08\xe7\x07\x02\x02\0\x01\x12\x03$\x07\x13\n\x0c\n\x05\x08\xe7\ + \x07\x02\x07\x12\x03$\x16+\n\x08\n\x01\x08\x12\x03%\0+\n\x0b\n\x04\x08\ + \xe7\x07\x03\x12\x03%\0+\n\x0c\n\x05\x08\xe7\x07\x03\x02\x12\x03%\x07\ + \x1b\n\r\n\x06\x08\xe7\x07\x03\x02\0\x12\x03%\x07\x1b\n\x0e\n\x07\x08\ + \xe7\x07\x03\x02\0\x01\x12\x03%\x07\x1b\n\x0c\n\x05\x08\xe7\x07\x03\x07\ + \x12\x03%\x1e*\n\x08\n\x01\x08\x12\x03&\0\"\n\x0b\n\x04\x08\xe7\x07\x04\ + \x12\x03&\0\"\n\x0c\n\x05\x08\xe7\x07\x04\x02\x12\x03&\x07\x1a\n\r\n\x06\ + \x08\xe7\x07\x04\x02\0\x12\x03&\x07\x1a\n\x0e\n\x07\x08\xe7\x07\x04\x02\ + \0\x01\x12\x03&\x07\x1a\n\x0c\n\x05\x08\xe7\x07\x04\x03\x12\x03&\x1d!\n\ + \x08\n\x01\x08\x12\x03'\0!\n\x0b\n\x04\x08\xe7\x07\x05\x12\x03'\0!\n\x0c\ + \n\x05\x08\xe7\x07\x05\x02\x12\x03'\x07\x18\n\r\n\x06\x08\xe7\x07\x05\ + \x02\0\x12\x03'\x07\x18\n\x0e\n\x07\x08\xe7\x07\x05\x02\0\x01\x12\x03'\ + \x07\x18\n\x0c\n\x05\x08\xe7\x07\x05\x07\x12\x03'\x1b\x20\n\x08\n\x01\ + \x08\x12\x03(\0\x1f\n\x0b\n\x04\x08\xe7\x07\x06\x12\x03(\0\x1f\n\x0c\n\ + \x05\x08\xe7\x07\x06\x02\x12\x03(\x07\x17\n\r\n\x06\x08\xe7\x07\x06\x02\ + \0\x12\x03(\x07\x17\n\x0e\n\x07\x08\xe7\x07\x06\x02\0\x01\x12\x03(\x07\ + \x17\n\x0c\n\x05\x08\xe7\x07\x06\x03\x12\x03(\x1a\x1e\n\xfb\x02\n\x02\ + \x04\0\x12\x033\0\x10\x1a\xef\x02\x20A\x20generic\x20empty\x20message\ + \x20that\x20you\x20can\x20re-use\x20to\x20avoid\x20defining\x20duplicate\ + d\n\x20empty\x20messages\x20in\x20your\x20APIs.\x20A\x20typical\x20examp\ + le\x20is\x20to\x20use\x20it\x20as\x20the\x20request\n\x20or\x20the\x20re\ + sponse\x20type\x20of\x20an\x20API\x20method.\x20For\x20instance:\n\n\x20\ + \x20\x20\x20\x20service\x20Foo\x20{\n\x20\x20\x20\x20\x20\x20\x20rpc\x20\ + Bar(google.protobuf.Empty)\x20returns\x20(google.protobuf.Empty);\n\x20\ + \x20\x20\x20\x20}\n\n\x20The\x20JSON\x20representation\x20for\x20`Empty`\ + \x20is\x20empty\x20JSON\x20object\x20`{}`.\n\n\n\n\x03\x04\0\x01\x12\x03\ + 3\x08\rb\x06proto3\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/third_party/protobuf/src/well_known_types/field_mask.rs b/third_party/protobuf/src/well_known_types/field_mask.rs new file mode 100644 index 000000000..82c1ceba6 --- /dev/null +++ b/third_party/protobuf/src/well_known_types/field_mask.rs @@ -0,0 +1,417 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +use std::boxed::Box; + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +#[derive(PartialEq,Clone,Default)] +pub struct FieldMask { + // message fields + pub paths: ::protobuf::RepeatedField<::std::string::String>, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for FieldMask {} + +impl FieldMask { + pub fn new() -> FieldMask { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static FieldMask { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const FieldMask, + }; + unsafe { + instance.get(FieldMask::new) + } + } + + // repeated string paths = 1; + + pub fn clear_paths(&mut self) { + self.paths.clear(); + } + + // Param is passed by value, moved + pub fn set_paths(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { + self.paths = v; + } + + // Mutable pointer to the field. + pub fn mut_paths(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.paths + } + + // Take field + pub fn take_paths(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { + ::std::mem::replace(&mut self.paths, ::protobuf::RepeatedField::new()) + } + + pub fn get_paths(&self) -> &[::std::string::String] { + &self.paths + } + + fn get_paths_for_reflect(&self) -> &::protobuf::RepeatedField<::std::string::String> { + &self.paths + } + + fn mut_paths_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.paths + } +} + +impl ::protobuf::Message for FieldMask { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.paths)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + for value in &self.paths { + my_size += ::protobuf::rt::string_size(1, &value); + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + for v in &self.paths { + os.write_string(1, &v)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for FieldMask { + fn new() -> FieldMask { + FieldMask::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "paths", + FieldMask::get_paths_for_reflect, + FieldMask::mut_paths_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "FieldMask", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for FieldMask { + fn clear(&mut self) { + self.clear_paths(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for FieldMask { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for FieldMask { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x20google/protobuf/field_mask.proto\x12\x0fgoogle.protobuf\"!\n\tFiel\ + dMask\x12\x14\n\x05paths\x18\x01\x20\x03(\tR\x05pathsBN\n\x13com.google.\ + protobufB\x0eFieldMaskProtoP\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protob\ + uf.WellKnownTypesJ\xc3;\n\x07\x12\x05\x1e\0\xf4\x01\x01\n\xcc\x0c\n\x01\ + \x0c\x12\x03\x1e\0\x122\xc1\x0c\x20Protocol\x20Buffers\x20-\x20Google's\ + \x20data\x20interchange\x20format\n\x20Copyright\x202008\x20Google\x20In\ + c.\x20\x20All\x20rights\x20reserved.\n\x20https://developers.google.com/\ + protocol-buffers/\n\n\x20Redistribution\x20and\x20use\x20in\x20source\ + \x20and\x20binary\x20forms,\x20with\x20or\x20without\n\x20modification,\ + \x20are\x20permitted\x20provided\x20that\x20the\x20following\x20conditio\ + ns\x20are\n\x20met:\n\n\x20\x20\x20\x20\x20*\x20Redistributions\x20of\ + \x20source\x20code\x20must\x20retain\x20the\x20above\x20copyright\n\x20n\ + otice,\x20this\x20list\x20of\x20conditions\x20and\x20the\x20following\ + \x20disclaimer.\n\x20\x20\x20\x20\x20*\x20Redistributions\x20in\x20binar\ + y\x20form\x20must\x20reproduce\x20the\x20above\n\x20copyright\x20notice,\ + \x20this\x20list\x20of\x20conditions\x20and\x20the\x20following\x20discl\ + aimer\n\x20in\x20the\x20documentation\x20and/or\x20other\x20materials\ + \x20provided\x20with\x20the\n\x20distribution.\n\x20\x20\x20\x20\x20*\ + \x20Neither\x20the\x20name\x20of\x20Google\x20Inc.\x20nor\x20the\x20name\ + s\x20of\x20its\n\x20contributors\x20may\x20be\x20used\x20to\x20endorse\ + \x20or\x20promote\x20products\x20derived\x20from\n\x20this\x20software\ + \x20without\x20specific\x20prior\x20written\x20permission.\n\n\x20THIS\ + \x20SOFTWARE\x20IS\x20PROVIDED\x20BY\x20THE\x20COPYRIGHT\x20HOLDERS\x20A\ + ND\x20CONTRIBUTORS\n\x20\"AS\x20IS\"\x20AND\x20ANY\x20EXPRESS\x20OR\x20I\ + MPLIED\x20WARRANTIES,\x20INCLUDING,\x20BUT\x20NOT\n\x20LIMITED\x20TO,\ + \x20THE\x20IMPLIED\x20WARRANTIES\x20OF\x20MERCHANTABILITY\x20AND\x20FITN\ + ESS\x20FOR\n\x20A\x20PARTICULAR\x20PURPOSE\x20ARE\x20DISCLAIMED.\x20IN\ + \x20NO\x20EVENT\x20SHALL\x20THE\x20COPYRIGHT\n\x20OWNER\x20OR\x20CONTRIB\ + UTORS\x20BE\x20LIABLE\x20FOR\x20ANY\x20DIRECT,\x20INDIRECT,\x20INCIDENTA\ + L,\n\x20SPECIAL,\x20EXEMPLARY,\x20OR\x20CONSEQUENTIAL\x20DAMAGES\x20(INC\ + LUDING,\x20BUT\x20NOT\n\x20LIMITED\x20TO,\x20PROCUREMENT\x20OF\x20SUBSTI\ + TUTE\x20GOODS\x20OR\x20SERVICES;\x20LOSS\x20OF\x20USE,\n\x20DATA,\x20OR\ + \x20PROFITS;\x20OR\x20BUSINESS\x20INTERRUPTION)\x20HOWEVER\x20CAUSED\x20\ + AND\x20ON\x20ANY\n\x20THEORY\x20OF\x20LIABILITY,\x20WHETHER\x20IN\x20CON\ + TRACT,\x20STRICT\x20LIABILITY,\x20OR\x20TORT\n\x20(INCLUDING\x20NEGLIGEN\ + CE\x20OR\x20OTHERWISE)\x20ARISING\x20IN\x20ANY\x20WAY\x20OUT\x20OF\x20TH\ + E\x20USE\n\x20OF\x20THIS\x20SOFTWARE,\x20EVEN\x20IF\x20ADVISED\x20OF\x20\ + THE\x20POSSIBILITY\x20OF\x20SUCH\x20DAMAGE.\n\n\x08\n\x01\x02\x12\x03\ + \x20\x08\x17\n\x08\n\x01\x08\x12\x03\"\0;\n\x0b\n\x04\x08\xe7\x07\0\x12\ + \x03\"\0;\n\x0c\n\x05\x08\xe7\x07\0\x02\x12\x03\"\x07\x17\n\r\n\x06\x08\ + \xe7\x07\0\x02\0\x12\x03\"\x07\x17\n\x0e\n\x07\x08\xe7\x07\0\x02\0\x01\ + \x12\x03\"\x07\x17\n\x0c\n\x05\x08\xe7\x07\0\x07\x12\x03\"\x1a:\n\x08\n\ + \x01\x08\x12\x03#\0,\n\x0b\n\x04\x08\xe7\x07\x01\x12\x03#\0,\n\x0c\n\x05\ + \x08\xe7\x07\x01\x02\x12\x03#\x07\x13\n\r\n\x06\x08\xe7\x07\x01\x02\0\ + \x12\x03#\x07\x13\n\x0e\n\x07\x08\xe7\x07\x01\x02\0\x01\x12\x03#\x07\x13\ + \n\x0c\n\x05\x08\xe7\x07\x01\x07\x12\x03#\x16+\n\x08\n\x01\x08\x12\x03$\ + \0/\n\x0b\n\x04\x08\xe7\x07\x02\x12\x03$\0/\n\x0c\n\x05\x08\xe7\x07\x02\ + \x02\x12\x03$\x07\x1b\n\r\n\x06\x08\xe7\x07\x02\x02\0\x12\x03$\x07\x1b\n\ + \x0e\n\x07\x08\xe7\x07\x02\x02\0\x01\x12\x03$\x07\x1b\n\x0c\n\x05\x08\ + \xe7\x07\x02\x07\x12\x03$\x1e.\n\x08\n\x01\x08\x12\x03%\0\"\n\x0b\n\x04\ + \x08\xe7\x07\x03\x12\x03%\0\"\n\x0c\n\x05\x08\xe7\x07\x03\x02\x12\x03%\ + \x07\x1a\n\r\n\x06\x08\xe7\x07\x03\x02\0\x12\x03%\x07\x1a\n\x0e\n\x07\ + \x08\xe7\x07\x03\x02\0\x01\x12\x03%\x07\x1a\n\x0c\n\x05\x08\xe7\x07\x03\ + \x03\x12\x03%\x1d!\n\x08\n\x01\x08\x12\x03&\0!\n\x0b\n\x04\x08\xe7\x07\ + \x04\x12\x03&\0!\n\x0c\n\x05\x08\xe7\x07\x04\x02\x12\x03&\x07\x18\n\r\n\ + \x06\x08\xe7\x07\x04\x02\0\x12\x03&\x07\x18\n\x0e\n\x07\x08\xe7\x07\x04\ + \x02\0\x01\x12\x03&\x07\x18\n\x0c\n\x05\x08\xe7\x07\x04\x07\x12\x03&\x1b\ + \x20\n\xcd*\n\x02\x04\0\x12\x06\xf1\x01\0\xf4\x01\x01\x1a\xbe*\x20`Field\ + Mask`\x20represents\x20a\x20set\x20of\x20symbolic\x20field\x20paths,\x20\ + for\x20example:\n\n\x20\x20\x20\x20\x20paths:\x20\"f.a\"\n\x20\x20\x20\ + \x20\x20paths:\x20\"f.b.d\"\n\n\x20Here\x20`f`\x20represents\x20a\x20fie\ + ld\x20in\x20some\x20root\x20message,\x20`a`\x20and\x20`b`\n\x20fields\ + \x20in\x20the\x20message\x20found\x20in\x20`f`,\x20and\x20`d`\x20a\x20fi\ + eld\x20found\x20in\x20the\n\x20message\x20in\x20`f.b`.\n\n\x20Field\x20m\ + asks\x20are\x20used\x20to\x20specify\x20a\x20subset\x20of\x20fields\x20t\ + hat\x20should\x20be\n\x20returned\x20by\x20a\x20get\x20operation\x20or\ + \x20modified\x20by\x20an\x20update\x20operation.\n\x20Field\x20masks\x20\ + also\x20have\x20a\x20custom\x20JSON\x20encoding\x20(see\x20below).\n\n\ + \x20#\x20Field\x20Masks\x20in\x20Projections\n\n\x20When\x20used\x20in\ + \x20the\x20context\x20of\x20a\x20projection,\x20a\x20response\x20message\ + \x20or\n\x20sub-message\x20is\x20filtered\x20by\x20the\x20API\x20to\x20o\ + nly\x20contain\x20those\x20fields\x20as\n\x20specified\x20in\x20the\x20m\ + ask.\x20For\x20example,\x20if\x20the\x20mask\x20in\x20the\x20previous\n\ + \x20example\x20is\x20applied\x20to\x20a\x20response\x20message\x20as\x20\ + follows:\n\n\x20\x20\x20\x20\x20f\x20{\n\x20\x20\x20\x20\x20\x20\x20a\ + \x20:\x2022\n\x20\x20\x20\x20\x20\x20\x20b\x20{\n\x20\x20\x20\x20\x20\ + \x20\x20\x20\x20d\x20:\x201\n\x20\x20\x20\x20\x20\x20\x20\x20\x20x\x20:\ + \x202\n\x20\x20\x20\x20\x20\x20\x20}\n\x20\x20\x20\x20\x20\x20\x20y\x20:\ + \x2013\n\x20\x20\x20\x20\x20}\n\x20\x20\x20\x20\x20z:\x208\n\n\x20The\ + \x20result\x20will\x20not\x20contain\x20specific\x20values\x20for\x20fie\ + lds\x20x,y\x20and\x20z\n\x20(their\x20value\x20will\x20be\x20set\x20to\ + \x20the\x20default,\x20and\x20omitted\x20in\x20proto\x20text\n\x20output\ + ):\n\n\n\x20\x20\x20\x20\x20f\x20{\n\x20\x20\x20\x20\x20\x20\x20a\x20:\ + \x2022\n\x20\x20\x20\x20\x20\x20\x20b\x20{\n\x20\x20\x20\x20\x20\x20\x20\ + \x20\x20d\x20:\x201\n\x20\x20\x20\x20\x20\x20\x20}\n\x20\x20\x20\x20\x20\ + }\n\n\x20A\x20repeated\x20field\x20is\x20not\x20allowed\x20except\x20at\ + \x20the\x20last\x20position\x20of\x20a\n\x20paths\x20string.\n\n\x20If\ + \x20a\x20FieldMask\x20object\x20is\x20not\x20present\x20in\x20a\x20get\ + \x20operation,\x20the\n\x20operation\x20applies\x20to\x20all\x20fields\ + \x20(as\x20if\x20a\x20FieldMask\x20of\x20all\x20fields\n\x20had\x20been\ + \x20specified).\n\n\x20Note\x20that\x20a\x20field\x20mask\x20does\x20not\ + \x20necessarily\x20apply\x20to\x20the\n\x20top-level\x20response\x20mess\ + age.\x20In\x20case\x20of\x20a\x20REST\x20get\x20operation,\x20the\n\x20f\ + ield\x20mask\x20applies\x20directly\x20to\x20the\x20response,\x20but\x20\ + in\x20case\x20of\x20a\x20REST\n\x20list\x20operation,\x20the\x20mask\x20\ + instead\x20applies\x20to\x20each\x20individual\x20message\n\x20in\x20the\ + \x20returned\x20resource\x20list.\x20In\x20case\x20of\x20a\x20REST\x20cu\ + stom\x20method,\n\x20other\x20definitions\x20may\x20be\x20used.\x20Where\ + \x20the\x20mask\x20applies\x20will\x20be\n\x20clearly\x20documented\x20t\ + ogether\x20with\x20its\x20declaration\x20in\x20the\x20API.\x20\x20In\n\ + \x20any\x20case,\x20the\x20effect\x20on\x20the\x20returned\x20resource/r\ + esources\x20is\x20required\n\x20behavior\x20for\x20APIs.\n\n\x20#\x20Fie\ + ld\x20Masks\x20in\x20Update\x20Operations\n\n\x20A\x20field\x20mask\x20i\ + n\x20update\x20operations\x20specifies\x20which\x20fields\x20of\x20the\n\ + \x20targeted\x20resource\x20are\x20going\x20to\x20be\x20updated.\x20The\ + \x20API\x20is\x20required\n\x20to\x20only\x20change\x20the\x20values\x20\ + of\x20the\x20fields\x20as\x20specified\x20in\x20the\x20mask\n\x20and\x20\ + leave\x20the\x20others\x20untouched.\x20If\x20a\x20resource\x20is\x20pas\ + sed\x20in\x20to\n\x20describe\x20the\x20updated\x20values,\x20the\x20API\ + \x20ignores\x20the\x20values\x20of\x20all\n\x20fields\x20not\x20covered\ + \x20by\x20the\x20mask.\n\n\x20If\x20a\x20repeated\x20field\x20is\x20spec\ + ified\x20for\x20an\x20update\x20operation,\x20the\x20existing\n\x20repea\ + ted\x20values\x20in\x20the\x20target\x20resource\x20will\x20be\x20overwr\ + itten\x20by\x20the\x20new\x20values.\n\x20Note\x20that\x20a\x20repeated\ + \x20field\x20is\x20only\x20allowed\x20in\x20the\x20last\x20position\x20o\ + f\x20a\x20`paths`\n\x20string.\n\n\x20If\x20a\x20sub-message\x20is\x20sp\ + ecified\x20in\x20the\x20last\x20position\x20of\x20the\x20field\x20mask\ + \x20for\x20an\n\x20update\x20operation,\x20then\x20the\x20existing\x20su\ + b-message\x20in\x20the\x20target\x20resource\x20is\n\x20overwritten.\x20\ + Given\x20the\x20target\x20message:\n\n\x20\x20\x20\x20\x20f\x20{\n\x20\ + \x20\x20\x20\x20\x20\x20b\x20{\n\x20\x20\x20\x20\x20\x20\x20\x20\x20d\ + \x20:\x201\n\x20\x20\x20\x20\x20\x20\x20\x20\x20x\x20:\x202\n\x20\x20\ + \x20\x20\x20\x20\x20}\n\x20\x20\x20\x20\x20\x20\x20c\x20:\x201\n\x20\x20\ + \x20\x20\x20}\n\n\x20And\x20an\x20update\x20message:\n\n\x20\x20\x20\x20\ + \x20f\x20{\n\x20\x20\x20\x20\x20\x20\x20b\x20{\n\x20\x20\x20\x20\x20\x20\ + \x20\x20\x20d\x20:\x2010\n\x20\x20\x20\x20\x20\x20\x20}\n\x20\x20\x20\ + \x20\x20}\n\n\x20then\x20if\x20the\x20field\x20mask\x20is:\n\n\x20\x20pa\ + ths:\x20\"f.b\"\n\n\x20then\x20the\x20result\x20will\x20be:\n\n\x20\x20\ + \x20\x20\x20f\x20{\n\x20\x20\x20\x20\x20\x20\x20b\x20{\n\x20\x20\x20\x20\ + \x20\x20\x20\x20\x20d\x20:\x2010\n\x20\x20\x20\x20\x20\x20\x20}\n\x20\ + \x20\x20\x20\x20\x20\x20c\x20:\x201\n\x20\x20\x20\x20\x20}\n\n\x20Howeve\ + r,\x20if\x20the\x20update\x20mask\x20was:\n\n\x20\x20paths:\x20\"f.b.d\"\ + \n\n\x20then\x20the\x20result\x20would\x20be:\n\n\x20\x20\x20\x20\x20f\ + \x20{\n\x20\x20\x20\x20\x20\x20\x20b\x20{\n\x20\x20\x20\x20\x20\x20\x20\ + \x20\x20d\x20:\x2010\n\x20\x20\x20\x20\x20\x20\x20\x20\x20x\x20:\x202\n\ + \x20\x20\x20\x20\x20\x20\x20}\n\x20\x20\x20\x20\x20\x20\x20c\x20:\x201\n\ + \x20\x20\x20\x20\x20}\n\n\x20In\x20order\x20to\x20reset\x20a\x20field's\ + \x20value\x20to\x20the\x20default,\x20the\x20field\x20must\n\x20be\x20in\ + \x20the\x20mask\x20and\x20set\x20to\x20the\x20default\x20value\x20in\x20\ + the\x20provided\x20resource.\n\x20Hence,\x20in\x20order\x20to\x20reset\ + \x20all\x20fields\x20of\x20a\x20resource,\x20provide\x20a\x20default\n\ + \x20instance\x20of\x20the\x20resource\x20and\x20set\x20all\x20fields\x20\ + in\x20the\x20mask,\x20or\x20do\n\x20not\x20provide\x20a\x20mask\x20as\ + \x20described\x20below.\n\n\x20If\x20a\x20field\x20mask\x20is\x20not\x20\ + present\x20on\x20update,\x20the\x20operation\x20applies\x20to\n\x20all\ + \x20fields\x20(as\x20if\x20a\x20field\x20mask\x20of\x20all\x20fields\x20\ + has\x20been\x20specified).\n\x20Note\x20that\x20in\x20the\x20presence\ + \x20of\x20schema\x20evolution,\x20this\x20may\x20mean\x20that\n\x20field\ + s\x20the\x20client\x20does\x20not\x20know\x20and\x20has\x20therefore\x20\ + not\x20filled\x20into\n\x20the\x20request\x20will\x20be\x20reset\x20to\ + \x20their\x20default.\x20If\x20this\x20is\x20unwanted\n\x20behavior,\x20\ + a\x20specific\x20service\x20may\x20require\x20a\x20client\x20to\x20alway\ + s\x20specify\n\x20a\x20field\x20mask,\x20producing\x20an\x20error\x20if\ + \x20not.\n\n\x20As\x20with\x20get\x20operations,\x20the\x20location\x20o\ + f\x20the\x20resource\x20which\n\x20describes\x20the\x20updated\x20values\ + \x20in\x20the\x20request\x20message\x20depends\x20on\x20the\n\x20operati\ + on\x20kind.\x20In\x20any\x20case,\x20the\x20effect\x20of\x20the\x20field\ + \x20mask\x20is\n\x20required\x20to\x20be\x20honored\x20by\x20the\x20API.\ + \n\n\x20##\x20Considerations\x20for\x20HTTP\x20REST\n\n\x20The\x20HTTP\ + \x20kind\x20of\x20an\x20update\x20operation\x20which\x20uses\x20a\x20fie\ + ld\x20mask\x20must\n\x20be\x20set\x20to\x20PATCH\x20instead\x20of\x20PUT\ + \x20in\x20order\x20to\x20satisfy\x20HTTP\x20semantics\n\x20(PUT\x20must\ + \x20only\x20be\x20used\x20for\x20full\x20updates).\n\n\x20#\x20JSON\x20E\ + ncoding\x20of\x20Field\x20Masks\n\n\x20In\x20JSON,\x20a\x20field\x20mask\ + \x20is\x20encoded\x20as\x20a\x20single\x20string\x20where\x20paths\x20ar\ + e\n\x20separated\x20by\x20a\x20comma.\x20Fields\x20name\x20in\x20each\ + \x20path\x20are\x20converted\n\x20to/from\x20lower-camel\x20naming\x20co\ + nventions.\n\n\x20As\x20an\x20example,\x20consider\x20the\x20following\ + \x20message\x20declarations:\n\n\x20\x20\x20\x20\x20message\x20Profile\ + \x20{\n\x20\x20\x20\x20\x20\x20\x20User\x20user\x20=\x201;\n\x20\x20\x20\ + \x20\x20\x20\x20Photo\x20photo\x20=\x202;\n\x20\x20\x20\x20\x20}\n\x20\ + \x20\x20\x20\x20message\x20User\x20{\n\x20\x20\x20\x20\x20\x20\x20string\ + \x20display_name\x20=\x201;\n\x20\x20\x20\x20\x20\x20\x20string\x20addre\ + ss\x20=\x202;\n\x20\x20\x20\x20\x20}\n\n\x20In\x20proto\x20a\x20field\ + \x20mask\x20for\x20`Profile`\x20may\x20look\x20as\x20such:\n\n\x20\x20\ + \x20\x20\x20mask\x20{\n\x20\x20\x20\x20\x20\x20\x20paths:\x20\"user.disp\ + lay_name\"\n\x20\x20\x20\x20\x20\x20\x20paths:\x20\"photo\"\n\x20\x20\ + \x20\x20\x20}\n\n\x20In\x20JSON,\x20the\x20same\x20mask\x20is\x20represe\ + nted\x20as\x20below:\n\n\x20\x20\x20\x20\x20{\n\x20\x20\x20\x20\x20\x20\ + \x20mask:\x20\"user.displayName,photo\"\n\x20\x20\x20\x20\x20}\n\n\x20#\ + \x20Field\x20Masks\x20and\x20Oneof\x20Fields\n\n\x20Field\x20masks\x20tr\ + eat\x20fields\x20in\x20oneofs\x20just\x20as\x20regular\x20fields.\x20Con\ + sider\x20the\n\x20following\x20message:\n\n\x20\x20\x20\x20\x20message\ + \x20SampleMessage\x20{\n\x20\x20\x20\x20\x20\x20\x20oneof\x20test_oneof\ + \x20{\n\x20\x20\x20\x20\x20\x20\x20\x20\x20string\x20name\x20=\x204;\n\ + \x20\x20\x20\x20\x20\x20\x20\x20\x20SubMessage\x20sub_message\x20=\x209;\ + \n\x20\x20\x20\x20\x20\x20\x20}\n\x20\x20\x20\x20\x20}\n\n\x20The\x20fie\ + ld\x20mask\x20can\x20be:\n\n\x20\x20\x20\x20\x20mask\x20{\n\x20\x20\x20\ + \x20\x20\x20\x20paths:\x20\"name\"\n\x20\x20\x20\x20\x20}\n\n\x20Or:\n\n\ + \x20\x20\x20\x20\x20mask\x20{\n\x20\x20\x20\x20\x20\x20\x20paths:\x20\"s\ + ub_message\"\n\x20\x20\x20\x20\x20}\n\n\x20Note\x20that\x20oneof\x20type\ + \x20names\x20(\"test_oneof\"\x20in\x20this\x20case)\x20cannot\x20be\x20u\ + sed\x20in\n\x20paths.\n\n\x0b\n\x03\x04\0\x01\x12\x04\xf1\x01\x08\x11\n,\ + \n\x04\x04\0\x02\0\x12\x04\xf3\x01\x02\x1c\x1a\x1e\x20The\x20set\x20of\ + \x20field\x20mask\x20paths.\n\n\r\n\x05\x04\0\x02\0\x04\x12\x04\xf3\x01\ + \x02\n\n\r\n\x05\x04\0\x02\0\x05\x12\x04\xf3\x01\x0b\x11\n\r\n\x05\x04\0\ + \x02\0\x01\x12\x04\xf3\x01\x12\x17\n\r\n\x05\x04\0\x02\0\x03\x12\x04\xf3\ + \x01\x1a\x1bb\x06proto3\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/third_party/protobuf/src/well_known_types/mod.rs b/third_party/protobuf/src/well_known_types/mod.rs new file mode 100644 index 000000000..7ccc4990c --- /dev/null +++ b/third_party/protobuf/src/well_known_types/mod.rs @@ -0,0 +1,23 @@ +// This file is generated. Do not edit + +mod any; +mod api; +mod duration; +mod empty; +mod field_mask; +mod source_context; +mod struct_pb; +mod timestamp; +mod type_pb; +mod wrappers; + +pub use self::any::*; +pub use self::api::*; +pub use self::duration::*; +pub use self::empty::*; +pub use self::field_mask::*; +pub use self::source_context::*; +pub use self::struct_pb::*; +pub use self::timestamp::*; +pub use self::type_pb::*; +pub use self::wrappers::*; diff --git a/third_party/protobuf/src/well_known_types/source_context.rs b/third_party/protobuf/src/well_known_types/source_context.rs new file mode 100644 index 000000000..d982c09cf --- /dev/null +++ b/third_party/protobuf/src/well_known_types/source_context.rs @@ -0,0 +1,288 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +use std::boxed::Box; + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +#[derive(PartialEq,Clone,Default)] +pub struct SourceContext { + // message fields + pub file_name: ::std::string::String, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for SourceContext {} + +impl SourceContext { + pub fn new() -> SourceContext { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static SourceContext { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const SourceContext, + }; + unsafe { + instance.get(SourceContext::new) + } + } + + // string file_name = 1; + + pub fn clear_file_name(&mut self) { + self.file_name.clear(); + } + + // Param is passed by value, moved + pub fn set_file_name(&mut self, v: ::std::string::String) { + self.file_name = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_file_name(&mut self) -> &mut ::std::string::String { + &mut self.file_name + } + + // Take field + pub fn take_file_name(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.file_name, ::std::string::String::new()) + } + + pub fn get_file_name(&self) -> &str { + &self.file_name + } + + fn get_file_name_for_reflect(&self) -> &::std::string::String { + &self.file_name + } + + fn mut_file_name_for_reflect(&mut self) -> &mut ::std::string::String { + &mut self.file_name + } +} + +impl ::protobuf::Message for SourceContext { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.file_name)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.file_name.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.file_name); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.file_name.is_empty() { + os.write_string(1, &self.file_name)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for SourceContext { + fn new() -> SourceContext { + SourceContext::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "file_name", + SourceContext::get_file_name_for_reflect, + SourceContext::mut_file_name_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "SourceContext", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for SourceContext { + fn clear(&mut self) { + self.clear_file_name(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for SourceContext { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for SourceContext { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n$google/protobuf/source_context.proto\x12\x0fgoogle.protobuf\",\n\rSou\ + rceContext\x12\x1b\n\tfile_name\x18\x01\x20\x01(\tR\x08fileNameBR\n\x13c\ + om.google.protobufB\x12SourceContextProtoP\x01\xa2\x02\x03GPB\xaa\x02\ + \x1eGoogle.Protobuf.WellKnownTypesJ\xec\x12\n\x06\x12\x04\x1e\0.\x01\n\ + \xcc\x0c\n\x01\x0c\x12\x03\x1e\0\x122\xc1\x0c\x20Protocol\x20Buffers\x20\ + -\x20Google's\x20data\x20interchange\x20format\n\x20Copyright\x202008\ + \x20Google\x20Inc.\x20\x20All\x20rights\x20reserved.\n\x20https://develo\ + pers.google.com/protocol-buffers/\n\n\x20Redistribution\x20and\x20use\ + \x20in\x20source\x20and\x20binary\x20forms,\x20with\x20or\x20without\n\ + \x20modification,\x20are\x20permitted\x20provided\x20that\x20the\x20foll\ + owing\x20conditions\x20are\n\x20met:\n\n\x20\x20\x20\x20\x20*\x20Redistr\ + ibutions\x20of\x20source\x20code\x20must\x20retain\x20the\x20above\x20co\ + pyright\n\x20notice,\x20this\x20list\x20of\x20conditions\x20and\x20the\ + \x20following\x20disclaimer.\n\x20\x20\x20\x20\x20*\x20Redistributions\ + \x20in\x20binary\x20form\x20must\x20reproduce\x20the\x20above\n\x20copyr\ + ight\x20notice,\x20this\x20list\x20of\x20conditions\x20and\x20the\x20fol\ + lowing\x20disclaimer\n\x20in\x20the\x20documentation\x20and/or\x20other\ + \x20materials\x20provided\x20with\x20the\n\x20distribution.\n\x20\x20\ + \x20\x20\x20*\x20Neither\x20the\x20name\x20of\x20Google\x20Inc.\x20nor\ + \x20the\x20names\x20of\x20its\n\x20contributors\x20may\x20be\x20used\x20\ + to\x20endorse\x20or\x20promote\x20products\x20derived\x20from\n\x20this\ + \x20software\x20without\x20specific\x20prior\x20written\x20permission.\n\ + \n\x20THIS\x20SOFTWARE\x20IS\x20PROVIDED\x20BY\x20THE\x20COPYRIGHT\x20HO\ + LDERS\x20AND\x20CONTRIBUTORS\n\x20\"AS\x20IS\"\x20AND\x20ANY\x20EXPRESS\ + \x20OR\x20IMPLIED\x20WARRANTIES,\x20INCLUDING,\x20BUT\x20NOT\n\x20LIMITE\ + D\x20TO,\x20THE\x20IMPLIED\x20WARRANTIES\x20OF\x20MERCHANTABILITY\x20AND\ + \x20FITNESS\x20FOR\n\x20A\x20PARTICULAR\x20PURPOSE\x20ARE\x20DISCLAIMED.\ + \x20IN\x20NO\x20EVENT\x20SHALL\x20THE\x20COPYRIGHT\n\x20OWNER\x20OR\x20C\ + ONTRIBUTORS\x20BE\x20LIABLE\x20FOR\x20ANY\x20DIRECT,\x20INDIRECT,\x20INC\ + IDENTAL,\n\x20SPECIAL,\x20EXEMPLARY,\x20OR\x20CONSEQUENTIAL\x20DAMAGES\ + \x20(INCLUDING,\x20BUT\x20NOT\n\x20LIMITED\x20TO,\x20PROCUREMENT\x20OF\ + \x20SUBSTITUTE\x20GOODS\x20OR\x20SERVICES;\x20LOSS\x20OF\x20USE,\n\x20DA\ + TA,\x20OR\x20PROFITS;\x20OR\x20BUSINESS\x20INTERRUPTION)\x20HOWEVER\x20C\ + AUSED\x20AND\x20ON\x20ANY\n\x20THEORY\x20OF\x20LIABILITY,\x20WHETHER\x20\ + IN\x20CONTRACT,\x20STRICT\x20LIABILITY,\x20OR\x20TORT\n\x20(INCLUDING\ + \x20NEGLIGENCE\x20OR\x20OTHERWISE)\x20ARISING\x20IN\x20ANY\x20WAY\x20OUT\ + \x20OF\x20THE\x20USE\n\x20OF\x20THIS\x20SOFTWARE,\x20EVEN\x20IF\x20ADVIS\ + ED\x20OF\x20THE\x20POSSIBILITY\x20OF\x20SUCH\x20DAMAGE.\n\n\x08\n\x01\ + \x02\x12\x03\x20\x08\x17\n\x08\n\x01\x08\x12\x03\"\0;\n\x0b\n\x04\x08\ + \xe7\x07\0\x12\x03\"\0;\n\x0c\n\x05\x08\xe7\x07\0\x02\x12\x03\"\x07\x17\ + \n\r\n\x06\x08\xe7\x07\0\x02\0\x12\x03\"\x07\x17\n\x0e\n\x07\x08\xe7\x07\ + \0\x02\0\x01\x12\x03\"\x07\x17\n\x0c\n\x05\x08\xe7\x07\0\x07\x12\x03\"\ + \x1a:\n\x08\n\x01\x08\x12\x03#\0,\n\x0b\n\x04\x08\xe7\x07\x01\x12\x03#\0\ + ,\n\x0c\n\x05\x08\xe7\x07\x01\x02\x12\x03#\x07\x13\n\r\n\x06\x08\xe7\x07\ + \x01\x02\0\x12\x03#\x07\x13\n\x0e\n\x07\x08\xe7\x07\x01\x02\0\x01\x12\ + \x03#\x07\x13\n\x0c\n\x05\x08\xe7\x07\x01\x07\x12\x03#\x16+\n\x08\n\x01\ + \x08\x12\x03$\03\n\x0b\n\x04\x08\xe7\x07\x02\x12\x03$\03\n\x0c\n\x05\x08\ + \xe7\x07\x02\x02\x12\x03$\x07\x1b\n\r\n\x06\x08\xe7\x07\x02\x02\0\x12\ + \x03$\x07\x1b\n\x0e\n\x07\x08\xe7\x07\x02\x02\0\x01\x12\x03$\x07\x1b\n\ + \x0c\n\x05\x08\xe7\x07\x02\x07\x12\x03$\x1e2\n\x08\n\x01\x08\x12\x03%\0\ + \"\n\x0b\n\x04\x08\xe7\x07\x03\x12\x03%\0\"\n\x0c\n\x05\x08\xe7\x07\x03\ + \x02\x12\x03%\x07\x1a\n\r\n\x06\x08\xe7\x07\x03\x02\0\x12\x03%\x07\x1a\n\ + \x0e\n\x07\x08\xe7\x07\x03\x02\0\x01\x12\x03%\x07\x1a\n\x0c\n\x05\x08\ + \xe7\x07\x03\x03\x12\x03%\x1d!\n\x08\n\x01\x08\x12\x03&\0!\n\x0b\n\x04\ + \x08\xe7\x07\x04\x12\x03&\0!\n\x0c\n\x05\x08\xe7\x07\x04\x02\x12\x03&\ + \x07\x18\n\r\n\x06\x08\xe7\x07\x04\x02\0\x12\x03&\x07\x18\n\x0e\n\x07\ + \x08\xe7\x07\x04\x02\0\x01\x12\x03&\x07\x18\n\x0c\n\x05\x08\xe7\x07\x04\ + \x07\x12\x03&\x1b\x20\n\x83\x01\n\x02\x04\0\x12\x04*\0.\x01\x1aw\x20`Sou\ + rceContext`\x20represents\x20information\x20about\x20the\x20source\x20of\ + \x20a\n\x20protobuf\x20element,\x20like\x20the\x20file\x20in\x20which\ + \x20it\x20is\x20defined.\n\n\n\n\x03\x04\0\x01\x12\x03*\x08\x15\n\xa3\ + \x01\n\x04\x04\0\x02\0\x12\x03-\x02\x17\x1a\x95\x01\x20The\x20path-quali\ + fied\x20name\x20of\x20the\x20.proto\x20file\x20that\x20contained\x20the\ + \x20associated\n\x20protobuf\x20element.\x20\x20For\x20example:\x20`\"go\ + ogle/protobuf/source_context.proto\"`.\n\n\r\n\x05\x04\0\x02\0\x04\x12\ + \x04-\x02*\x17\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03-\x02\x08\n\x0c\n\x05\ + \x04\0\x02\0\x01\x12\x03-\t\x12\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03-\x15\ + \x16b\x06proto3\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/third_party/protobuf/src/well_known_types/struct_pb.rs b/third_party/protobuf/src/well_known_types/struct_pb.rs new file mode 100644 index 000000000..7224b8b3c --- /dev/null +++ b/third_party/protobuf/src/well_known_types/struct_pb.rs @@ -0,0 +1,1077 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +use std::boxed::Box; + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +#[derive(PartialEq,Clone,Default)] +pub struct Struct { + // message fields + pub fields: ::std::collections::HashMap<::std::string::String, Value>, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for Struct {} + +impl Struct { + pub fn new() -> Struct { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static Struct { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Struct, + }; + unsafe { + instance.get(Struct::new) + } + } + + // repeated .google.protobuf.Struct.FieldsEntry fields = 1; + + pub fn clear_fields(&mut self) { + self.fields.clear(); + } + + // Param is passed by value, moved + pub fn set_fields(&mut self, v: ::std::collections::HashMap<::std::string::String, Value>) { + self.fields = v; + } + + // Mutable pointer to the field. + pub fn mut_fields(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Value> { + &mut self.fields + } + + // Take field + pub fn take_fields(&mut self) -> ::std::collections::HashMap<::std::string::String, Value> { + ::std::mem::replace(&mut self.fields, ::std::collections::HashMap::new()) + } + + pub fn get_fields(&self) -> &::std::collections::HashMap<::std::string::String, Value> { + &self.fields + } + + fn get_fields_for_reflect(&self) -> &::std::collections::HashMap<::std::string::String, Value> { + &self.fields + } + + fn mut_fields_for_reflect(&mut self) -> &mut ::std::collections::HashMap<::std::string::String, Value> { + &mut self.fields + } +} + +impl ::protobuf::Message for Struct { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_map_into::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(wire_type, is, &mut self.fields)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::compute_map_size::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.fields); + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + ::protobuf::rt::write_map_with_cached_sizes::<::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>(1, &self.fields, os)?; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for Struct { + fn new() -> Struct { + Struct::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_map_accessor::<_, ::protobuf::types::ProtobufTypeString, ::protobuf::types::ProtobufTypeMessage>( + "fields", + Struct::get_fields_for_reflect, + Struct::mut_fields_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Struct", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for Struct { + fn clear(&mut self) { + self.clear_fields(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Struct { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Struct { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Value { + // message oneof groups + kind: ::std::option::Option, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for Value {} + +#[derive(Clone,PartialEq)] +pub enum Value_oneof_kind { + null_value(NullValue), + number_value(f64), + string_value(::std::string::String), + bool_value(bool), + struct_value(Struct), + list_value(ListValue), +} + +impl Value { + pub fn new() -> Value { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static Value { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Value, + }; + unsafe { + instance.get(Value::new) + } + } + + // .google.protobuf.NullValue null_value = 1; + + pub fn clear_null_value(&mut self) { + self.kind = ::std::option::Option::None; + } + + pub fn has_null_value(&self) -> bool { + match self.kind { + ::std::option::Option::Some(Value_oneof_kind::null_value(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_null_value(&mut self, v: NullValue) { + self.kind = ::std::option::Option::Some(Value_oneof_kind::null_value(v)) + } + + pub fn get_null_value(&self) -> NullValue { + match self.kind { + ::std::option::Option::Some(Value_oneof_kind::null_value(v)) => v, + _ => NullValue::NULL_VALUE, + } + } + + // double number_value = 2; + + pub fn clear_number_value(&mut self) { + self.kind = ::std::option::Option::None; + } + + pub fn has_number_value(&self) -> bool { + match self.kind { + ::std::option::Option::Some(Value_oneof_kind::number_value(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_number_value(&mut self, v: f64) { + self.kind = ::std::option::Option::Some(Value_oneof_kind::number_value(v)) + } + + pub fn get_number_value(&self) -> f64 { + match self.kind { + ::std::option::Option::Some(Value_oneof_kind::number_value(v)) => v, + _ => 0., + } + } + + // string string_value = 3; + + pub fn clear_string_value(&mut self) { + self.kind = ::std::option::Option::None; + } + + pub fn has_string_value(&self) -> bool { + match self.kind { + ::std::option::Option::Some(Value_oneof_kind::string_value(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_string_value(&mut self, v: ::std::string::String) { + self.kind = ::std::option::Option::Some(Value_oneof_kind::string_value(v)) + } + + // Mutable pointer to the field. + pub fn mut_string_value(&mut self) -> &mut ::std::string::String { + if let ::std::option::Option::Some(Value_oneof_kind::string_value(_)) = self.kind { + } else { + self.kind = ::std::option::Option::Some(Value_oneof_kind::string_value(::std::string::String::new())); + } + match self.kind { + ::std::option::Option::Some(Value_oneof_kind::string_value(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_string_value(&mut self) -> ::std::string::String { + if self.has_string_value() { + match self.kind.take() { + ::std::option::Option::Some(Value_oneof_kind::string_value(v)) => v, + _ => panic!(), + } + } else { + ::std::string::String::new() + } + } + + pub fn get_string_value(&self) -> &str { + match self.kind { + ::std::option::Option::Some(Value_oneof_kind::string_value(ref v)) => v, + _ => "", + } + } + + // bool bool_value = 4; + + pub fn clear_bool_value(&mut self) { + self.kind = ::std::option::Option::None; + } + + pub fn has_bool_value(&self) -> bool { + match self.kind { + ::std::option::Option::Some(Value_oneof_kind::bool_value(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_bool_value(&mut self, v: bool) { + self.kind = ::std::option::Option::Some(Value_oneof_kind::bool_value(v)) + } + + pub fn get_bool_value(&self) -> bool { + match self.kind { + ::std::option::Option::Some(Value_oneof_kind::bool_value(v)) => v, + _ => false, + } + } + + // .google.protobuf.Struct struct_value = 5; + + pub fn clear_struct_value(&mut self) { + self.kind = ::std::option::Option::None; + } + + pub fn has_struct_value(&self) -> bool { + match self.kind { + ::std::option::Option::Some(Value_oneof_kind::struct_value(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_struct_value(&mut self, v: Struct) { + self.kind = ::std::option::Option::Some(Value_oneof_kind::struct_value(v)) + } + + // Mutable pointer to the field. + pub fn mut_struct_value(&mut self) -> &mut Struct { + if let ::std::option::Option::Some(Value_oneof_kind::struct_value(_)) = self.kind { + } else { + self.kind = ::std::option::Option::Some(Value_oneof_kind::struct_value(Struct::new())); + } + match self.kind { + ::std::option::Option::Some(Value_oneof_kind::struct_value(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_struct_value(&mut self) -> Struct { + if self.has_struct_value() { + match self.kind.take() { + ::std::option::Option::Some(Value_oneof_kind::struct_value(v)) => v, + _ => panic!(), + } + } else { + Struct::new() + } + } + + pub fn get_struct_value(&self) -> &Struct { + match self.kind { + ::std::option::Option::Some(Value_oneof_kind::struct_value(ref v)) => v, + _ => Struct::default_instance(), + } + } + + // .google.protobuf.ListValue list_value = 6; + + pub fn clear_list_value(&mut self) { + self.kind = ::std::option::Option::None; + } + + pub fn has_list_value(&self) -> bool { + match self.kind { + ::std::option::Option::Some(Value_oneof_kind::list_value(..)) => true, + _ => false, + } + } + + // Param is passed by value, moved + pub fn set_list_value(&mut self, v: ListValue) { + self.kind = ::std::option::Option::Some(Value_oneof_kind::list_value(v)) + } + + // Mutable pointer to the field. + pub fn mut_list_value(&mut self) -> &mut ListValue { + if let ::std::option::Option::Some(Value_oneof_kind::list_value(_)) = self.kind { + } else { + self.kind = ::std::option::Option::Some(Value_oneof_kind::list_value(ListValue::new())); + } + match self.kind { + ::std::option::Option::Some(Value_oneof_kind::list_value(ref mut v)) => v, + _ => panic!(), + } + } + + // Take field + pub fn take_list_value(&mut self) -> ListValue { + if self.has_list_value() { + match self.kind.take() { + ::std::option::Option::Some(Value_oneof_kind::list_value(v)) => v, + _ => panic!(), + } + } else { + ListValue::new() + } + } + + pub fn get_list_value(&self) -> &ListValue { + match self.kind { + ::std::option::Option::Some(Value_oneof_kind::list_value(ref v)) => v, + _ => ListValue::default_instance(), + } + } +} + +impl ::protobuf::Message for Value { + fn is_initialized(&self) -> bool { + if let Some(Value_oneof_kind::struct_value(ref v)) = self.kind { + if !v.is_initialized() { + return false; + } + } + if let Some(Value_oneof_kind::list_value(ref v)) = self.kind { + if !v.is_initialized() { + return false; + } + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.kind = ::std::option::Option::Some(Value_oneof_kind::null_value(is.read_enum()?)); + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeFixed64 { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.kind = ::std::option::Option::Some(Value_oneof_kind::number_value(is.read_double()?)); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.kind = ::std::option::Option::Some(Value_oneof_kind::string_value(is.read_string()?)); + }, + 4 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.kind = ::std::option::Option::Some(Value_oneof_kind::bool_value(is.read_bool()?)); + }, + 5 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.kind = ::std::option::Option::Some(Value_oneof_kind::struct_value(is.read_message()?)); + }, + 6 => { + if wire_type != ::protobuf::wire_format::WireTypeLengthDelimited { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + self.kind = ::std::option::Option::Some(Value_oneof_kind::list_value(is.read_message()?)); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let ::std::option::Option::Some(ref v) = self.kind { + match v { + &Value_oneof_kind::null_value(v) => { + my_size += ::protobuf::rt::enum_size(1, v); + }, + &Value_oneof_kind::number_value(v) => { + my_size += 9; + }, + &Value_oneof_kind::string_value(ref v) => { + my_size += ::protobuf::rt::string_size(3, &v); + }, + &Value_oneof_kind::bool_value(v) => { + my_size += 2; + }, + &Value_oneof_kind::struct_value(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + &Value_oneof_kind::list_value(ref v) => { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }, + }; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if let ::std::option::Option::Some(ref v) = self.kind { + match v { + &Value_oneof_kind::null_value(v) => { + os.write_enum(1, v.value())?; + }, + &Value_oneof_kind::number_value(v) => { + os.write_double(2, v)?; + }, + &Value_oneof_kind::string_value(ref v) => { + os.write_string(3, v)?; + }, + &Value_oneof_kind::bool_value(v) => { + os.write_bool(4, v)?; + }, + &Value_oneof_kind::struct_value(ref v) => { + os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + &Value_oneof_kind::list_value(ref v) => { + os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }, + }; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for Value { + fn new() -> Value { + Value::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_enum_accessor::<_, NullValue>( + "null_value", + Value::has_null_value, + Value::get_null_value, + )); + fields.push(::protobuf::reflect::accessor::make_singular_f64_accessor::<_>( + "number_value", + Value::has_number_value, + Value::get_number_value, + )); + fields.push(::protobuf::reflect::accessor::make_singular_string_accessor::<_>( + "string_value", + Value::has_string_value, + Value::get_string_value, + )); + fields.push(::protobuf::reflect::accessor::make_singular_bool_accessor::<_>( + "bool_value", + Value::has_bool_value, + Value::get_bool_value, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, Struct>( + "struct_value", + Value::has_struct_value, + Value::get_struct_value, + )); + fields.push(::protobuf::reflect::accessor::make_singular_message_accessor::<_, ListValue>( + "list_value", + Value::has_list_value, + Value::get_list_value, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Value", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for Value { + fn clear(&mut self) { + self.clear_null_value(); + self.clear_number_value(); + self.clear_string_value(); + self.clear_bool_value(); + self.clear_struct_value(); + self.clear_list_value(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Value { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Value { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct ListValue { + // message fields + pub values: ::protobuf::RepeatedField, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for ListValue {} + +impl ListValue { + pub fn new() -> ListValue { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static ListValue { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ListValue, + }; + unsafe { + instance.get(ListValue::new) + } + } + + // repeated .google.protobuf.Value values = 1; + + pub fn clear_values(&mut self) { + self.values.clear(); + } + + // Param is passed by value, moved + pub fn set_values(&mut self, v: ::protobuf::RepeatedField) { + self.values = v; + } + + // Mutable pointer to the field. + pub fn mut_values(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.values + } + + // Take field + pub fn take_values(&mut self) -> ::protobuf::RepeatedField { + ::std::mem::replace(&mut self.values, ::protobuf::RepeatedField::new()) + } + + pub fn get_values(&self) -> &[Value] { + &self.values + } + + fn get_values_for_reflect(&self) -> &::protobuf::RepeatedField { + &self.values + } + + fn mut_values_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { + &mut self.values + } +} + +impl ::protobuf::Message for ListValue { + fn is_initialized(&self) -> bool { + for v in &self.values { + if !v.is_initialized() { + return false; + } + }; + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.values)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + for value in &self.values { + let len = value.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + for v in &self.values { + os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for ListValue { + fn new() -> ListValue { + ListValue::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "values", + ListValue::get_values_for_reflect, + ListValue::mut_values_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "ListValue", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for ListValue { + fn clear(&mut self) { + self.clear_values(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for ListValue { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for ListValue { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum NullValue { + NULL_VALUE = 0, +} + +impl ::protobuf::ProtobufEnum for NullValue { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(NullValue::NULL_VALUE), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [NullValue] = &[ + NullValue::NULL_VALUE, + ]; + values + } + + fn enum_descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::EnumDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::EnumDescriptor, + }; + unsafe { + descriptor.get(|| { + ::protobuf::reflect::EnumDescriptor::new("NullValue", file_descriptor_proto()) + }) + } + } +} + +impl ::std::marker::Copy for NullValue { +} + +impl ::std::default::Default for NullValue { + fn default() -> Self { + NullValue::NULL_VALUE + } +} + +impl ::protobuf::reflect::ProtobufValue for NullValue { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x1cgoogle/protobuf/struct.proto\x12\x0fgoogle.protobuf\"\x98\x01\n\ + \x06Struct\x12;\n\x06fields\x18\x01\x20\x03(\x0b2#.google.protobuf.Struc\ + t.FieldsEntryR\x06fields\x1aQ\n\x0bFieldsEntry\x12\x10\n\x03key\x18\x01\ + \x20\x01(\tR\x03key\x12,\n\x05value\x18\x02\x20\x01(\x0b2\x16.google.pro\ + tobuf.ValueR\x05value:\x028\x01\"\xb2\x02\n\x05Value\x12;\n\nnull_value\ + \x18\x01\x20\x01(\x0e2\x1a.google.protobuf.NullValueH\0R\tnullValue\x12#\ + \n\x0cnumber_value\x18\x02\x20\x01(\x01H\0R\x0bnumberValue\x12#\n\x0cstr\ + ing_value\x18\x03\x20\x01(\tH\0R\x0bstringValue\x12\x1f\n\nbool_value\ + \x18\x04\x20\x01(\x08H\0R\tboolValue\x12<\n\x0cstruct_value\x18\x05\x20\ + \x01(\x0b2\x17.google.protobuf.StructH\0R\x0bstructValue\x12;\n\nlist_va\ + lue\x18\x06\x20\x01(\x0b2\x1a.google.protobuf.ListValueH\0R\tlistValueB\ + \x06\n\x04kind\";\n\tListValue\x12.\n\x06values\x18\x01\x20\x03(\x0b2\ + \x16.google.protobuf.ValueR\x06values*\x1b\n\tNullValue\x12\x0e\n\nNULL_\ + VALUE\x10\0B\x81\x01\n\x13com.google.protobufB\x0bStructProtoP\x01Z1gith\ + ub.com/golang/protobuf/ptypes/struct;structpb\xf8\x01\x01\xa2\x02\x03GPB\ + \xaa\x02\x1eGoogle.Protobuf.WellKnownTypesJ\xd3\x20\n\x06\x12\x04\x1e\0_\ + \x01\n\xcc\x0c\n\x01\x0c\x12\x03\x1e\0\x122\xc1\x0c\x20Protocol\x20Buffe\ + rs\x20-\x20Google's\x20data\x20interchange\x20format\n\x20Copyright\x202\ + 008\x20Google\x20Inc.\x20\x20All\x20rights\x20reserved.\n\x20https://dev\ + elopers.google.com/protocol-buffers/\n\n\x20Redistribution\x20and\x20use\ + \x20in\x20source\x20and\x20binary\x20forms,\x20with\x20or\x20without\n\ + \x20modification,\x20are\x20permitted\x20provided\x20that\x20the\x20foll\ + owing\x20conditions\x20are\n\x20met:\n\n\x20\x20\x20\x20\x20*\x20Redistr\ + ibutions\x20of\x20source\x20code\x20must\x20retain\x20the\x20above\x20co\ + pyright\n\x20notice,\x20this\x20list\x20of\x20conditions\x20and\x20the\ + \x20following\x20disclaimer.\n\x20\x20\x20\x20\x20*\x20Redistributions\ + \x20in\x20binary\x20form\x20must\x20reproduce\x20the\x20above\n\x20copyr\ + ight\x20notice,\x20this\x20list\x20of\x20conditions\x20and\x20the\x20fol\ + lowing\x20disclaimer\n\x20in\x20the\x20documentation\x20and/or\x20other\ + \x20materials\x20provided\x20with\x20the\n\x20distribution.\n\x20\x20\ + \x20\x20\x20*\x20Neither\x20the\x20name\x20of\x20Google\x20Inc.\x20nor\ + \x20the\x20names\x20of\x20its\n\x20contributors\x20may\x20be\x20used\x20\ + to\x20endorse\x20or\x20promote\x20products\x20derived\x20from\n\x20this\ + \x20software\x20without\x20specific\x20prior\x20written\x20permission.\n\ + \n\x20THIS\x20SOFTWARE\x20IS\x20PROVIDED\x20BY\x20THE\x20COPYRIGHT\x20HO\ + LDERS\x20AND\x20CONTRIBUTORS\n\x20\"AS\x20IS\"\x20AND\x20ANY\x20EXPRESS\ + \x20OR\x20IMPLIED\x20WARRANTIES,\x20INCLUDING,\x20BUT\x20NOT\n\x20LIMITE\ + D\x20TO,\x20THE\x20IMPLIED\x20WARRANTIES\x20OF\x20MERCHANTABILITY\x20AND\ + \x20FITNESS\x20FOR\n\x20A\x20PARTICULAR\x20PURPOSE\x20ARE\x20DISCLAIMED.\ + \x20IN\x20NO\x20EVENT\x20SHALL\x20THE\x20COPYRIGHT\n\x20OWNER\x20OR\x20C\ + ONTRIBUTORS\x20BE\x20LIABLE\x20FOR\x20ANY\x20DIRECT,\x20INDIRECT,\x20INC\ + IDENTAL,\n\x20SPECIAL,\x20EXEMPLARY,\x20OR\x20CONSEQUENTIAL\x20DAMAGES\ + \x20(INCLUDING,\x20BUT\x20NOT\n\x20LIMITED\x20TO,\x20PROCUREMENT\x20OF\ + \x20SUBSTITUTE\x20GOODS\x20OR\x20SERVICES;\x20LOSS\x20OF\x20USE,\n\x20DA\ + TA,\x20OR\x20PROFITS;\x20OR\x20BUSINESS\x20INTERRUPTION)\x20HOWEVER\x20C\ + AUSED\x20AND\x20ON\x20ANY\n\x20THEORY\x20OF\x20LIABILITY,\x20WHETHER\x20\ + IN\x20CONTRACT,\x20STRICT\x20LIABILITY,\x20OR\x20TORT\n\x20(INCLUDING\ + \x20NEGLIGENCE\x20OR\x20OTHERWISE)\x20ARISING\x20IN\x20ANY\x20WAY\x20OUT\ + \x20OF\x20THE\x20USE\n\x20OF\x20THIS\x20SOFTWARE,\x20EVEN\x20IF\x20ADVIS\ + ED\x20OF\x20THE\x20POSSIBILITY\x20OF\x20SUCH\x20DAMAGE.\n\n\x08\n\x01\ + \x02\x12\x03\x20\x08\x17\n\x08\n\x01\x08\x12\x03\"\0;\n\x0b\n\x04\x08\ + \xe7\x07\0\x12\x03\"\0;\n\x0c\n\x05\x08\xe7\x07\0\x02\x12\x03\"\x07\x17\ + \n\r\n\x06\x08\xe7\x07\0\x02\0\x12\x03\"\x07\x17\n\x0e\n\x07\x08\xe7\x07\ + \0\x02\0\x01\x12\x03\"\x07\x17\n\x0c\n\x05\x08\xe7\x07\0\x07\x12\x03\"\ + \x1a:\n\x08\n\x01\x08\x12\x03#\0\x1f\n\x0b\n\x04\x08\xe7\x07\x01\x12\x03\ + #\0\x1f\n\x0c\n\x05\x08\xe7\x07\x01\x02\x12\x03#\x07\x17\n\r\n\x06\x08\ + \xe7\x07\x01\x02\0\x12\x03#\x07\x17\n\x0e\n\x07\x08\xe7\x07\x01\x02\0\ + \x01\x12\x03#\x07\x17\n\x0c\n\x05\x08\xe7\x07\x01\x03\x12\x03#\x1a\x1e\n\ + \x08\n\x01\x08\x12\x03$\0H\n\x0b\n\x04\x08\xe7\x07\x02\x12\x03$\0H\n\x0c\ + \n\x05\x08\xe7\x07\x02\x02\x12\x03$\x07\x11\n\r\n\x06\x08\xe7\x07\x02\ + \x02\0\x12\x03$\x07\x11\n\x0e\n\x07\x08\xe7\x07\x02\x02\0\x01\x12\x03$\ + \x07\x11\n\x0c\n\x05\x08\xe7\x07\x02\x07\x12\x03$\x14G\n\x08\n\x01\x08\ + \x12\x03%\0,\n\x0b\n\x04\x08\xe7\x07\x03\x12\x03%\0,\n\x0c\n\x05\x08\xe7\ + \x07\x03\x02\x12\x03%\x07\x13\n\r\n\x06\x08\xe7\x07\x03\x02\0\x12\x03%\ + \x07\x13\n\x0e\n\x07\x08\xe7\x07\x03\x02\0\x01\x12\x03%\x07\x13\n\x0c\n\ + \x05\x08\xe7\x07\x03\x07\x12\x03%\x16+\n\x08\n\x01\x08\x12\x03&\0,\n\x0b\ + \n\x04\x08\xe7\x07\x04\x12\x03&\0,\n\x0c\n\x05\x08\xe7\x07\x04\x02\x12\ + \x03&\x07\x1b\n\r\n\x06\x08\xe7\x07\x04\x02\0\x12\x03&\x07\x1b\n\x0e\n\ + \x07\x08\xe7\x07\x04\x02\0\x01\x12\x03&\x07\x1b\n\x0c\n\x05\x08\xe7\x07\ + \x04\x07\x12\x03&\x1e+\n\x08\n\x01\x08\x12\x03'\0\"\n\x0b\n\x04\x08\xe7\ + \x07\x05\x12\x03'\0\"\n\x0c\n\x05\x08\xe7\x07\x05\x02\x12\x03'\x07\x1a\n\ + \r\n\x06\x08\xe7\x07\x05\x02\0\x12\x03'\x07\x1a\n\x0e\n\x07\x08\xe7\x07\ + \x05\x02\0\x01\x12\x03'\x07\x1a\n\x0c\n\x05\x08\xe7\x07\x05\x03\x12\x03'\ + \x1d!\n\x08\n\x01\x08\x12\x03(\0!\n\x0b\n\x04\x08\xe7\x07\x06\x12\x03(\0\ + !\n\x0c\n\x05\x08\xe7\x07\x06\x02\x12\x03(\x07\x18\n\r\n\x06\x08\xe7\x07\ + \x06\x02\0\x12\x03(\x07\x18\n\x0e\n\x07\x08\xe7\x07\x06\x02\0\x01\x12\ + \x03(\x07\x18\n\x0c\n\x05\x08\xe7\x07\x06\x07\x12\x03(\x1b\x20\n\xb3\x03\ + \n\x02\x04\0\x12\x043\06\x01\x1a\xa6\x03\x20`Struct`\x20represents\x20a\ + \x20structured\x20data\x20value,\x20consisting\x20of\x20fields\n\x20whic\ + h\x20map\x20to\x20dynamically\x20typed\x20values.\x20In\x20some\x20langu\ + ages,\x20`Struct`\n\x20might\x20be\x20supported\x20by\x20a\x20native\x20\ + representation.\x20For\x20example,\x20in\n\x20scripting\x20languages\x20\ + like\x20JS\x20a\x20struct\x20is\x20represented\x20as\x20an\n\x20object.\ + \x20The\x20details\x20of\x20that\x20representation\x20are\x20described\ + \x20together\n\x20with\x20the\x20proto\x20support\x20for\x20the\x20langu\ + age.\n\n\x20The\x20JSON\x20representation\x20for\x20`Struct`\x20is\x20JS\ + ON\x20object.\n\n\n\n\x03\x04\0\x01\x12\x033\x08\x0e\n9\n\x04\x04\0\x02\ + \0\x12\x035\x02\x20\x1a,\x20Unordered\x20map\x20of\x20dynamically\x20typ\ + ed\x20values.\n\n\r\n\x05\x04\0\x02\0\x04\x12\x045\x023\x10\n\x0c\n\x05\ + \x04\0\x02\0\x06\x12\x035\x02\x14\n\x0c\n\x05\x04\0\x02\0\x01\x12\x035\ + \x15\x1b\n\x0c\n\x05\x04\0\x02\0\x03\x12\x035\x1e\x1f\n\xc3\x02\n\x02\ + \x04\x01\x12\x04>\0N\x01\x1a\xb6\x02\x20`Value`\x20represents\x20a\x20dy\ + namically\x20typed\x20value\x20which\x20can\x20be\x20either\n\x20null,\ + \x20a\x20number,\x20a\x20string,\x20a\x20boolean,\x20a\x20recursive\x20s\ + truct\x20value,\x20or\x20a\n\x20list\x20of\x20values.\x20A\x20producer\ + \x20of\x20value\x20is\x20expected\x20to\x20set\x20one\x20of\x20that\n\ + \x20variants,\x20absence\x20of\x20any\x20variant\x20indicates\x20an\x20e\ + rror.\n\n\x20The\x20JSON\x20representation\x20for\x20`Value`\x20is\x20JS\ + ON\x20value.\n\n\n\n\x03\x04\x01\x01\x12\x03>\x08\r\n\"\n\x04\x04\x01\ + \x08\0\x12\x04@\x02M\x03\x1a\x14\x20The\x20kind\x20of\x20value.\n\n\x0c\ + \n\x05\x04\x01\x08\0\x01\x12\x03@\x08\x0c\n'\n\x04\x04\x01\x02\0\x12\x03\ + B\x04\x1d\x1a\x1a\x20Represents\x20a\x20null\x20value.\n\n\x0c\n\x05\x04\ + \x01\x02\0\x06\x12\x03B\x04\r\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03B\x0e\ + \x18\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03B\x1b\x1c\n)\n\x04\x04\x01\x02\ + \x01\x12\x03D\x04\x1c\x1a\x1c\x20Represents\x20a\x20double\x20value.\n\n\ + \x0c\n\x05\x04\x01\x02\x01\x05\x12\x03D\x04\n\n\x0c\n\x05\x04\x01\x02\ + \x01\x01\x12\x03D\x0b\x17\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03D\x1a\ + \x1b\n)\n\x04\x04\x01\x02\x02\x12\x03F\x04\x1c\x1a\x1c\x20Represents\x20\ + a\x20string\x20value.\n\n\x0c\n\x05\x04\x01\x02\x02\x05\x12\x03F\x04\n\n\ + \x0c\n\x05\x04\x01\x02\x02\x01\x12\x03F\x0b\x17\n\x0c\n\x05\x04\x01\x02\ + \x02\x03\x12\x03F\x1a\x1b\n*\n\x04\x04\x01\x02\x03\x12\x03H\x04\x18\x1a\ + \x1d\x20Represents\x20a\x20boolean\x20value.\n\n\x0c\n\x05\x04\x01\x02\ + \x03\x05\x12\x03H\x04\x08\n\x0c\n\x05\x04\x01\x02\x03\x01\x12\x03H\t\x13\ + \n\x0c\n\x05\x04\x01\x02\x03\x03\x12\x03H\x16\x17\n-\n\x04\x04\x01\x02\ + \x04\x12\x03J\x04\x1c\x1a\x20\x20Represents\x20a\x20structured\x20value.\ + \n\n\x0c\n\x05\x04\x01\x02\x04\x06\x12\x03J\x04\n\n\x0c\n\x05\x04\x01\ + \x02\x04\x01\x12\x03J\x0b\x17\n\x0c\n\x05\x04\x01\x02\x04\x03\x12\x03J\ + \x1a\x1b\n-\n\x04\x04\x01\x02\x05\x12\x03L\x04\x1d\x1a\x20\x20Represents\ + \x20a\x20repeated\x20`Value`.\n\n\x0c\n\x05\x04\x01\x02\x05\x06\x12\x03L\ + \x04\r\n\x0c\n\x05\x04\x01\x02\x05\x01\x12\x03L\x0e\x18\n\x0c\n\x05\x04\ + \x01\x02\x05\x03\x12\x03L\x1b\x1c\n\xa9\x01\n\x02\x05\0\x12\x04T\0W\x01\ + \x1a\x9c\x01\x20`NullValue`\x20is\x20a\x20singleton\x20enumeration\x20to\ + \x20represent\x20the\x20null\x20value\x20for\x20the\n\x20`Value`\x20type\ + \x20union.\n\n\x20\x20The\x20JSON\x20representation\x20for\x20`NullValue\ + `\x20is\x20JSON\x20`null`.\n\n\n\n\x03\x05\0\x01\x12\x03T\x05\x0e\n\x1a\ + \n\x04\x05\0\x02\0\x12\x03V\x02\x11\x1a\r\x20Null\x20value.\n\n\x0c\n\ + \x05\x05\0\x02\0\x01\x12\x03V\x02\x0c\n\x0c\n\x05\x05\0\x02\0\x02\x12\ + \x03V\x0f\x10\n\x82\x01\n\x02\x04\x02\x12\x04\\\0_\x01\x1av\x20`ListValu\ + e`\x20is\x20a\x20wrapper\x20around\x20a\x20repeated\x20field\x20of\x20va\ + lues.\n\n\x20The\x20JSON\x20representation\x20for\x20`ListValue`\x20is\ + \x20JSON\x20array.\n\n\n\n\x03\x04\x02\x01\x12\x03\\\x08\x11\n:\n\x04\ + \x04\x02\x02\0\x12\x03^\x02\x1c\x1a-\x20Repeated\x20field\x20of\x20dynam\ + ically\x20typed\x20values.\n\n\x0c\n\x05\x04\x02\x02\0\x04\x12\x03^\x02\ + \n\n\x0c\n\x05\x04\x02\x02\0\x06\x12\x03^\x0b\x10\n\x0c\n\x05\x04\x02\ + \x02\0\x01\x12\x03^\x11\x17\n\x0c\n\x05\x04\x02\x02\0\x03\x12\x03^\x1a\ + \x1bb\x06proto3\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/third_party/protobuf/src/well_known_types/timestamp.rs b/third_party/protobuf/src/well_known_types/timestamp.rs new file mode 100644 index 000000000..9c6a3ab70 --- /dev/null +++ b/third_party/protobuf/src/well_known_types/timestamp.rs @@ -0,0 +1,379 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +use std::boxed::Box; + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +#[derive(PartialEq,Clone,Default)] +pub struct Timestamp { + // message fields + pub seconds: i64, + pub nanos: i32, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +// see codegen.rs for the explanation why impl Sync explicitly +unsafe impl ::std::marker::Sync for Timestamp {} + +impl Timestamp { + pub fn new() -> Timestamp { + ::std::default::Default::default() + } + + pub fn default_instance() -> &'static Timestamp { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Timestamp, + }; + unsafe { + instance.get(Timestamp::new) + } + } + + // int64 seconds = 1; + + pub fn clear_seconds(&mut self) { + self.seconds = 0; + } + + // Param is passed by value, moved + pub fn set_seconds(&mut self, v: i64) { + self.seconds = v; + } + + pub fn get_seconds(&self) -> i64 { + self.seconds + } + + fn get_seconds_for_reflect(&self) -> &i64 { + &self.seconds + } + + fn mut_seconds_for_reflect(&mut self) -> &mut i64 { + &mut self.seconds + } + + // int32 nanos = 2; + + pub fn clear_nanos(&mut self) { + self.nanos = 0; + } + + // Param is passed by value, moved + pub fn set_nanos(&mut self, v: i32) { + self.nanos = v; + } + + pub fn get_nanos(&self) -> i32 { + self.nanos + } + + fn get_nanos_for_reflect(&self) -> &i32 { + &self.nanos + } + + fn mut_nanos_for_reflect(&mut self) -> &mut i32 { + &mut self.nanos + } +} + +impl ::protobuf::Message for Timestamp { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int64()?; + self.seconds = tmp; + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int32()?; + self.nanos = tmp; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if self.seconds != 0 { + my_size += ::protobuf::rt::value_size(1, self.seconds, ::protobuf::wire_format::WireTypeVarint); + } + if self.nanos != 0 { + my_size += ::protobuf::rt::value_size(2, self.nanos, ::protobuf::wire_format::WireTypeVarint); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if self.seconds != 0 { + os.write_int64(1, self.seconds)?; + } + if self.nanos != 0 { + os.write_int32(2, self.nanos)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + ::protobuf::MessageStatic::descriptor_static(None::) + } +} + +impl ::protobuf::MessageStatic for Timestamp { + fn new() -> Timestamp { + Timestamp::new() + } + + fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( + "seconds", + Timestamp::get_seconds_for_reflect, + Timestamp::mut_seconds_for_reflect, + )); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt32>( + "nanos", + Timestamp::get_nanos_for_reflect, + Timestamp::mut_nanos_for_reflect, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Timestamp", + fields, + file_descriptor_proto() + ) + }) + } + } +} + +impl ::protobuf::Clear for Timestamp { + fn clear(&mut self) { + self.clear_seconds(); + self.clear_nanos(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Timestamp { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Timestamp { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x1fgoogle/protobuf/timestamp.proto\x12\x0fgoogle.protobuf\";\n\tTimes\ + tamp\x12\x18\n\x07seconds\x18\x01\x20\x01(\x03R\x07seconds\x12\x14\n\x05\ + nanos\x18\x02\x20\x01(\x05R\x05nanosB~\n\x13com.google.protobufB\x0eTime\ + stampProtoP\x01Z+github.com/golang/protobuf/ptypes/timestamp\xf8\x01\x01\ + \xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesJ\xde$\n\x06\ + \x12\x04\x1e\0k\x01\n\xcc\x0c\n\x01\x0c\x12\x03\x1e\0\x122\xc1\x0c\x20Pr\ + otocol\x20Buffers\x20-\x20Google's\x20data\x20interchange\x20format\n\ + \x20Copyright\x202008\x20Google\x20Inc.\x20\x20All\x20rights\x20reserved\ + .\n\x20https://developers.google.com/protocol-buffers/\n\n\x20Redistribu\ + tion\x20and\x20use\x20in\x20source\x20and\x20binary\x20forms,\x20with\ + \x20or\x20without\n\x20modification,\x20are\x20permitted\x20provided\x20\ + that\x20the\x20following\x20conditions\x20are\n\x20met:\n\n\x20\x20\x20\ + \x20\x20*\x20Redistributions\x20of\x20source\x20code\x20must\x20retain\ + \x20the\x20above\x20copyright\n\x20notice,\x20this\x20list\x20of\x20cond\ + itions\x20and\x20the\x20following\x20disclaimer.\n\x20\x20\x20\x20\x20*\ + \x20Redistributions\x20in\x20binary\x20form\x20must\x20reproduce\x20the\ + \x20above\n\x20copyright\x20notice,\x20this\x20list\x20of\x20conditions\ + \x20and\x20the\x20following\x20disclaimer\n\x20in\x20the\x20documentatio\ + n\x20and/or\x20other\x20materials\x20provided\x20with\x20the\n\x20distri\ + bution.\n\x20\x20\x20\x20\x20*\x20Neither\x20the\x20name\x20of\x20Google\ + \x20Inc.\x20nor\x20the\x20names\x20of\x20its\n\x20contributors\x20may\ + \x20be\x20used\x20to\x20endorse\x20or\x20promote\x20products\x20derived\ + \x20from\n\x20this\x20software\x20without\x20specific\x20prior\x20writte\ + n\x20permission.\n\n\x20THIS\x20SOFTWARE\x20IS\x20PROVIDED\x20BY\x20THE\ + \x20COPYRIGHT\x20HOLDERS\x20AND\x20CONTRIBUTORS\n\x20\"AS\x20IS\"\x20AND\ + \x20ANY\x20EXPRESS\x20OR\x20IMPLIED\x20WARRANTIES,\x20INCLUDING,\x20BUT\ + \x20NOT\n\x20LIMITED\x20TO,\x20THE\x20IMPLIED\x20WARRANTIES\x20OF\x20MER\ + CHANTABILITY\x20AND\x20FITNESS\x20FOR\n\x20A\x20PARTICULAR\x20PURPOSE\ + \x20ARE\x20DISCLAIMED.\x20IN\x20NO\x20EVENT\x20SHALL\x20THE\x20COPYRIGHT\ + \n\x20OWNER\x20OR\x20CONTRIBUTORS\x20BE\x20LIABLE\x20FOR\x20ANY\x20DIREC\ + T,\x20INDIRECT,\x20INCIDENTAL,\n\x20SPECIAL,\x20EXEMPLARY,\x20OR\x20CONS\ + EQUENTIAL\x20DAMAGES\x20(INCLUDING,\x20BUT\x20NOT\n\x20LIMITED\x20TO,\ + \x20PROCUREMENT\x20OF\x20SUBSTITUTE\x20GOODS\x20OR\x20SERVICES;\x20LOSS\ + \x20OF\x20USE,\n\x20DATA,\x20OR\x20PROFITS;\x20OR\x20BUSINESS\x20INTERRU\ + PTION)\x20HOWEVER\x20CAUSED\x20AND\x20ON\x20ANY\n\x20THEORY\x20OF\x20LIA\ + BILITY,\x20WHETHER\x20IN\x20CONTRACT,\x20STRICT\x20LIABILITY,\x20OR\x20T\ + ORT\n\x20(INCLUDING\x20NEGLIGENCE\x20OR\x20OTHERWISE)\x20ARISING\x20IN\ + \x20ANY\x20WAY\x20OUT\x20OF\x20THE\x20USE\n\x20OF\x20THIS\x20SOFTWARE,\ + \x20EVEN\x20IF\x20ADVISED\x20OF\x20THE\x20POSSIBILITY\x20OF\x20SUCH\x20D\ + AMAGE.\n\n\x08\n\x01\x02\x12\x03\x20\x08\x17\n\x08\n\x01\x08\x12\x03\"\0\ + ;\n\x0b\n\x04\x08\xe7\x07\0\x12\x03\"\0;\n\x0c\n\x05\x08\xe7\x07\0\x02\ + \x12\x03\"\x07\x17\n\r\n\x06\x08\xe7\x07\0\x02\0\x12\x03\"\x07\x17\n\x0e\ + \n\x07\x08\xe7\x07\0\x02\0\x01\x12\x03\"\x07\x17\n\x0c\n\x05\x08\xe7\x07\ + \0\x07\x12\x03\"\x1a:\n\x08\n\x01\x08\x12\x03#\0\x1f\n\x0b\n\x04\x08\xe7\ + \x07\x01\x12\x03#\0\x1f\n\x0c\n\x05\x08\xe7\x07\x01\x02\x12\x03#\x07\x17\ + \n\r\n\x06\x08\xe7\x07\x01\x02\0\x12\x03#\x07\x17\n\x0e\n\x07\x08\xe7\ + \x07\x01\x02\0\x01\x12\x03#\x07\x17\n\x0c\n\x05\x08\xe7\x07\x01\x03\x12\ + \x03#\x1a\x1e\n\x08\n\x01\x08\x12\x03$\0B\n\x0b\n\x04\x08\xe7\x07\x02\ + \x12\x03$\0B\n\x0c\n\x05\x08\xe7\x07\x02\x02\x12\x03$\x07\x11\n\r\n\x06\ + \x08\xe7\x07\x02\x02\0\x12\x03$\x07\x11\n\x0e\n\x07\x08\xe7\x07\x02\x02\ + \0\x01\x12\x03$\x07\x11\n\x0c\n\x05\x08\xe7\x07\x02\x07\x12\x03$\x14A\n\ + \x08\n\x01\x08\x12\x03%\0,\n\x0b\n\x04\x08\xe7\x07\x03\x12\x03%\0,\n\x0c\ + \n\x05\x08\xe7\x07\x03\x02\x12\x03%\x07\x13\n\r\n\x06\x08\xe7\x07\x03\ + \x02\0\x12\x03%\x07\x13\n\x0e\n\x07\x08\xe7\x07\x03\x02\0\x01\x12\x03%\ + \x07\x13\n\x0c\n\x05\x08\xe7\x07\x03\x07\x12\x03%\x16+\n\x08\n\x01\x08\ + \x12\x03&\0/\n\x0b\n\x04\x08\xe7\x07\x04\x12\x03&\0/\n\x0c\n\x05\x08\xe7\ + \x07\x04\x02\x12\x03&\x07\x1b\n\r\n\x06\x08\xe7\x07\x04\x02\0\x12\x03&\ + \x07\x1b\n\x0e\n\x07\x08\xe7\x07\x04\x02\0\x01\x12\x03&\x07\x1b\n\x0c\n\ + \x05\x08\xe7\x07\x04\x07\x12\x03&\x1e.\n\x08\n\x01\x08\x12\x03'\0\"\n\ + \x0b\n\x04\x08\xe7\x07\x05\x12\x03'\0\"\n\x0c\n\x05\x08\xe7\x07\x05\x02\ + \x12\x03'\x07\x1a\n\r\n\x06\x08\xe7\x07\x05\x02\0\x12\x03'\x07\x1a\n\x0e\ + \n\x07\x08\xe7\x07\x05\x02\0\x01\x12\x03'\x07\x1a\n\x0c\n\x05\x08\xe7\ + \x07\x05\x03\x12\x03'\x1d!\n\x08\n\x01\x08\x12\x03(\0!\n\x0b\n\x04\x08\ + \xe7\x07\x06\x12\x03(\0!\n\x0c\n\x05\x08\xe7\x07\x06\x02\x12\x03(\x07\ + \x18\n\r\n\x06\x08\xe7\x07\x06\x02\0\x12\x03(\x07\x18\n\x0e\n\x07\x08\ + \xe7\x07\x06\x02\0\x01\x12\x03(\x07\x18\n\x0c\n\x05\x08\xe7\x07\x06\x07\ + \x12\x03(\x1b\x20\n\xb8\x0f\n\x02\x04\0\x12\x04_\0k\x01\x1a\xab\x0f\x20A\ + \x20Timestamp\x20represents\x20a\x20point\x20in\x20time\x20independent\ + \x20of\x20any\x20time\x20zone\n\x20or\x20calendar,\x20represented\x20as\ + \x20seconds\x20and\x20fractions\x20of\x20seconds\x20at\n\x20nanosecond\ + \x20resolution\x20in\x20UTC\x20Epoch\x20time.\x20It\x20is\x20encoded\x20\ + using\x20the\n\x20Proleptic\x20Gregorian\x20Calendar\x20which\x20extends\ + \x20the\x20Gregorian\x20calendar\n\x20backwards\x20to\x20year\x20one.\ + \x20It\x20is\x20encoded\x20assuming\x20all\x20minutes\x20are\x2060\n\x20\ + seconds\x20long,\x20i.e.\x20leap\x20seconds\x20are\x20\"smeared\"\x20so\ + \x20that\x20no\x20leap\x20second\n\x20table\x20is\x20needed\x20for\x20in\ + terpretation.\x20Range\x20is\x20from\n\x200001-01-01T00:00:00Z\x20to\x20\ + 9999-12-31T23:59:59.999999999Z.\n\x20By\x20restricting\x20to\x20that\x20\ + range,\x20we\x20ensure\x20that\x20we\x20can\x20convert\x20to\n\x20and\ + \x20from\x20\x20RFC\x203339\x20date\x20strings.\n\x20See\x20[https://www\ + .ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).\n\n\ + \x20Example\x201:\x20Compute\x20Timestamp\x20from\x20POSIX\x20`time()`.\ + \n\n\x20\x20\x20\x20\x20Timestamp\x20timestamp;\n\x20\x20\x20\x20\x20tim\ + estamp.set_seconds(time(NULL));\n\x20\x20\x20\x20\x20timestamp.set_nanos\ + (0);\n\n\x20Example\x202:\x20Compute\x20Timestamp\x20from\x20POSIX\x20`g\ + ettimeofday()`.\n\n\x20\x20\x20\x20\x20struct\x20timeval\x20tv;\n\x20\ + \x20\x20\x20\x20gettimeofday(&tv,\x20NULL);\n\n\x20\x20\x20\x20\x20Times\ + tamp\x20timestamp;\n\x20\x20\x20\x20\x20timestamp.set_seconds(tv.tv_sec)\ + ;\n\x20\x20\x20\x20\x20timestamp.set_nanos(tv.tv_usec\x20*\x201000);\n\n\ + \x20Example\x203:\x20Compute\x20Timestamp\x20from\x20Win32\x20`GetSystem\ + TimeAsFileTime()`.\n\n\x20\x20\x20\x20\x20FILETIME\x20ft;\n\x20\x20\x20\ + \x20\x20GetSystemTimeAsFileTime(&ft);\n\x20\x20\x20\x20\x20UINT64\x20tic\ + ks\x20=\x20(((UINT64)ft.dwHighDateTime)\x20<<\x2032)\x20|\x20ft.dwLowDat\ + eTime;\n\n\x20\x20\x20\x20\x20//\x20A\x20Windows\x20tick\x20is\x20100\ + \x20nanoseconds.\x20Windows\x20epoch\x201601-01-01T00:00:00Z\n\x20\x20\ + \x20\x20\x20//\x20is\x2011644473600\x20seconds\x20before\x20Unix\x20epoc\ + h\x201970-01-01T00:00:00Z.\n\x20\x20\x20\x20\x20Timestamp\x20timestamp;\ + \n\x20\x20\x20\x20\x20timestamp.set_seconds((INT64)\x20((ticks\x20/\x201\ + 0000000)\x20-\x2011644473600LL));\n\x20\x20\x20\x20\x20timestamp.set_nan\ + os((INT32)\x20((ticks\x20%\x2010000000)\x20*\x20100));\n\n\x20Example\ + \x204:\x20Compute\x20Timestamp\x20from\x20Java\x20`System.currentTimeMil\ + lis()`.\n\n\x20\x20\x20\x20\x20long\x20millis\x20=\x20System.currentTime\ + Millis();\n\n\x20\x20\x20\x20\x20Timestamp\x20timestamp\x20=\x20Timestam\ + p.newBuilder().setSeconds(millis\x20/\x201000)\n\x20\x20\x20\x20\x20\x20\ + \x20\x20\x20.setNanos((int)\x20((millis\x20%\x201000)\x20*\x201000000)).\ + build();\n\n\n\x20Example\x205:\x20Compute\x20Timestamp\x20from\x20curre\ + nt\x20time\x20in\x20Python.\n\n\x20\x20\x20\x20\x20timestamp\x20=\x20Tim\ + estamp()\n\x20\x20\x20\x20\x20timestamp.GetCurrentTime()\n\n\n\n\n\n\x03\ + \x04\0\x01\x12\x03_\x08\x11\n\x9c\x01\n\x04\x04\0\x02\0\x12\x03d\x02\x14\ + \x1a\x8e\x01\x20Represents\x20seconds\x20of\x20UTC\x20time\x20since\x20U\ + nix\x20epoch\n\x201970-01-01T00:00:00Z.\x20Must\x20be\x20from\x200001-01\ + -01T00:00:00Z\x20to\n\x209999-12-31T23:59:59Z\x20inclusive.\n\n\r\n\x05\ + \x04\0\x02\0\x04\x12\x04d\x02_\x13\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03d\ + \x02\x07\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03d\x08\x0f\n\x0c\n\x05\x04\0\ + \x02\0\x03\x12\x03d\x12\x13\n\xe4\x01\n\x04\x04\0\x02\x01\x12\x03j\x02\ + \x12\x1a\xd6\x01\x20Non-negative\x20fractions\x20of\x20a\x20second\x20at\ + \x20nanosecond\x20resolution.\x20Negative\n\x20second\x20values\x20with\ + \x20fractions\x20must\x20still\x20have\x20non-negative\x20nanos\x20value\ + s\n\x20that\x20count\x20forward\x20in\x20time.\x20Must\x20be\x20from\x20\ + 0\x20to\x20999,999,999\n\x20inclusive.\n\n\r\n\x05\x04\0\x02\x01\x04\x12\ + \x04j\x02d\x14\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03j\x02\x07\n\x0c\n\ + \x05\x04\0\x02\x01\x01\x12\x03j\x08\r\n\x0c\n\x05\x04\0\x02\x01\x03\x12\ + \x03j\x10\x11b\x06proto3\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/third_party/protobuf/src/well_known_types/type_pb.rs b/third_party/protobuf/src/well_known_types/type_pb.rs new file mode 100644 index 000000000..81578d5d3 --- /dev/null +++ b/third_party/protobuf/src/well_known_types/type_pb.rs @@ -0,0 +1,2531 @@ +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +use std::boxed::Box; + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +#[derive(PartialEq,Clone,Default)] +pub struct Type { + // message fields + pub name: ::std::string::String, + pub fields: ::protobuf::RepeatedField, + pub oneofs: ::protobuf::RepeatedField<::std::string::String>, + pub options: ::protobuf::RepeatedField