b-r-u / osmpbf

A Rust library for reading the OpenStreetMap PBF file format (*.osm.pbf).
Apache License 2.0
122 stars 19 forks source link

Stop instantiating ProtobufError due to upstream changes #22

Closed nyurik closed 2 years ago

nyurik commented 2 years ago

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

b-r-u commented 2 years ago

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.

nyurik commented 2 years ago

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

b-r-u commented 2 years ago

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

nyurik commented 2 years ago

@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?

nyurik commented 2 years ago

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

nyurik commented 2 years ago

closing this issue as its main goal is solved

b-r-u commented 2 years ago

@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.