forked from tikv/raft-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the old way to read enum (tikv#75)
- Loading branch information
Showing
3 changed files
with
18 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters