New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_bytes
for Buf
trait
#374
Milestone
Comments
I think this is fixed by #439. |
Yep 👍 |
kbleeke
added a commit
to kbleeke/prost
that referenced
this issue
Mar 19, 2021
I just noticed this while poking through the code. Fields of type `Bytes` can now be slices of a greater `Bytes` that is passed to Message::decode The referenced issue tokio-rs/bytes#374 was implemented as Buf::copy_to_bytes and `Bytes` features the zero-copy implementation https://docs.rs/bytes/1.0.1/src/bytes/bytes.rs.html#526-560
danburkert
pushed a commit
to tokio-rs/prost
that referenced
this issue
Mar 21, 2021
I just noticed this while poking through the code. Fields of type `Bytes` can now be slices of a greater `Bytes` that is passed to Message::decode The referenced issue tokio-rs/bytes#374 was implemented as Buf::copy_to_bytes and `Bytes` features the zero-copy implementation https://docs.rs/bytes/1.0.1/src/bytes/bytes.rs.html#526-560
ryaminal
pushed a commit
to vivint-smarthome/prost
that referenced
this issue
Apr 8, 2021
I just noticed this while poking through the code. Fields of type `Bytes` can now be slices of a greater `Bytes` that is passed to Message::decode The referenced issue tokio-rs/bytes#374 was implemented as Buf::copy_to_bytes and `Bytes` features the zero-copy implementation https://docs.rs/bytes/1.0.1/src/bytes/bytes.rs.html#526-560
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fn get_bytes(&mut self, size: usize) -> Bytes
This is somewhat similar to #228 but for reading from a
Buf
.The idea is that a
Buf
implementation may already have an efficient way to get a "view" of some of its bytes that does not involve an expensive copy. The default implementation would just allocate a newBytes
object and then usecopy_to_slice
.The
Bytes
type could have a specialized implementation that just callssplit_to
on itself. In the future it may be possible to specialize the implementation ofBuf
for&'static [u8]
too, sinceBytes
can cope with that, or maybeBytes
will get an optional lifetime parameter allowing it to hold reference of any lifetime.The text was updated successfully, but these errors were encountered: