b-r-u / osmpbf

A Rust library for reading the OpenStreetMap PBF file format (*.osm.pbf).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stop instantiating ProtobufError due to upstream changes

nyurik opened this issue · comments

The protobuf v3 has made this change:

Rename ProtobufError to Error and make it opaque type

This means that osmpbf can no longer use ProtobufError::message_not_initialized("") in the https://github.com/b-r-u/osmpbf/blob/1a6b2d9ab4fd4985e1f6ecfe3a151316aea3ba2e/src/util.rs file (parse_message_from_bytes and parse_message_from_reader)

This change should be made before migrating to protobuf v3 to make sure the upgrade PR is easier to review. @b-r-u do you have any suggestions here? Or do you want to make this change?

See also #23

Hey nyurik! I removed the util module as there are now equivalent functions in protobuf itself. It looks like there are no instantiations of ProtobufError left.

LOL, i think we did near-identical change for this at the same time!

Wow! I think you could even remove every instance of CodedInputStream and call parse_from_bytes directly. It uses a CodedInputStream internally.

@b-r-u i was thinking about it, but internally it calls is.check_eof()?; -- are you certain that each byte buffer will be exactly the size of the message?

P.S. I migrated to protobuf3 -- see #23

closing this issue as its main goal is solved

@b-r-u i was thinking about it, but internally it calls is.check_eof()?; -- are you certain that each byte buffer will be exactly the size of the message?

That's a good point. I looked at the code and I'm quite certain that each call to parse_from_bytes should hand over a complete message without some extra bytes at the end.