Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the old way to read enum #75

Merged
merged 2 commits into from
Jun 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ categories = ["algorithms", "database-implementations"]

[dependencies]
log = "0.4.1"
protobuf = "2.0"
protobuf = "~2.0.0"
quick-error = "1.2.1"
rand = "0.4"
fxhash = "0.2.1"
Expand Down
13 changes: 13 additions & 0 deletions generate-proto.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
protoc proto/eraftpb.proto --rust_out=src/
# TODO: remove this once stepancheg/rust-protobuf#233 is resolved.
python <<EOF
import re
with open("src/eraftpb.rs") as reader:
src = reader.read()

res = re.sub('::protobuf::rt::read_proto3_enum_with_unknown_fields_into\(([^,]+), ([^,]+), &mut ([^,]+), [^\)]+\)\?', 'if \\\\1 == ::protobuf::wire_format::WireTypeVarint {\\\\3 = \\\\2.read_enum()?;} else { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); }', src)

with open("src/eraftpb.rs", "w") as writer:
writer.write(res)
EOF
8 changes: 4 additions & 4 deletions src/eraftpb.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 1.6.0. Do not edit
// This file is generated by rust-protobuf 2.0.2. Do not edit
// @generated

// https://github.com/Manishearth/rust-clippy/issues/702
Expand Down Expand Up @@ -163,7 +163,7 @@ impl ::protobuf::Message for Entry {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.entry_type, 1, &mut self.unknown_fields)?
if wire_type == ::protobuf::wire_format::WireTypeVarint {self.entry_type = is.read_enum()?;} else { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); }
},
2 => {
if wire_type != ::protobuf::wire_format::WireTypeVarint {
Expand Down Expand Up @@ -1095,7 +1095,7 @@ impl ::protobuf::Message for Message {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.msg_type, 1, &mut self.unknown_fields)?
if wire_type == ::protobuf::wire_format::WireTypeVarint {self.msg_type = is.read_enum()?;} else { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); }
},
2 => {
if wire_type != ::protobuf::wire_format::WireTypeVarint {
Expand Down Expand Up @@ -1945,7 +1945,7 @@ impl ::protobuf::Message for ConfChange {
self.id = tmp;
},
2 => {
::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.change_type, 2, &mut self.unknown_fields)?
if wire_type == ::protobuf::wire_format::WireTypeVarint {self.change_type = is.read_enum()?;} else { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); }
},
3 => {
if wire_type != ::protobuf::wire_format::WireTypeVarint {
Expand Down