rust-protobuf icon indicating copy to clipboard operation
rust-protobuf copied to clipboard

Parse from bytes::Bytes iterator

Open shirok1 opened this issue 2 years ago • 1 comments

Solve my #611 . BytesIteratorReader lacks document and test, please tell me the convention to add them.

shirok1 avatar Feb 25 '22 11:02 shirok1

There's an issue with this PR.

This PR does reading by wrapping Iterator<&Bytes> into Read. Which means CodedInputStream has no option to reuse underlying Bytes objects without copying them into memory. When CodedInputStream is constructed from Bytes, and when Bytes is requested (when tokio_bytes codegen option is used, see CodedInputStream::read_raw_tokio_bytes function), the generated messages bytes reference original Bytes object allocation, not create new allocation (which might be much more efficient).

In current form the PR does nothing which cannot be done outside of the crate.

stepancheg avatar Feb 27 '22 00:02 stepancheg