tafia / quick-protobuf

A rust implementation of protobuf parser
MIT License
452 stars 87 forks source link

Docs: add example of decoding non-length prefixed message #52

Closed koivunej closed 7 years ago

koivunej commented 7 years ago

This works with latest rust-protobuf, test case can be found in gist:

https://gist.github.com/koivunej/68321c230287f95f88816c278d721d16

It'd seem that problem is in reader::BytesReader::read_message assumes length delimited contents. My use case is to read protobuf messages from inside an already framed stream. I can't seem to find any support for reading without the length prefix, so I guess that needs to be added?

tafia commented 7 years ago

Yes I guess the API is not well documented. The bytesreader tries indeed to read a message which means he expects length then a message.

For your use case you're supposed to call message::from_reader directly.

We should probably both update the doc and change the function name

koivunej commented 7 years ago

Also, it'd seem that I've broken the deserialization code as well while debugging, added an extra read_tag.. :) I'll update the gist.

For your use case you're supposed to call message::from_reader directly.

Thanks, trying this next!

koivunej commented 7 years ago

Yes, this solves the problem. Perhaps I'll edit this to be about updating the docs and send a PR later on.