Implement Bytes::unsplit and Bytes::try_unsplit#819
Implement Bytes::unsplit and Bytes::try_unsplit#819thanhminhmr wants to merge 4 commits intotokio-rs:masterfrom
Bytes::unsplit and Bytes::try_unsplit#819Conversation
071b73c to
4c6e308
Compare
|
The pub fn unsplit(mut self, other: Bytes) -> Self;Absorbs a Otherwise, this method tries to convert use bytes::Bytes;
let mut buf = Bytes::from_static(b"aaabbbcccddd");
let split = buf.split_off(6);
assert_eq!(b"aaabbb", &buf[..]);
assert_eq!(b"cccddd", &split[..]);
let buf = buf.unsplit(split);
assert_eq!(b"aaabbbcccddd", &buf[..]); |
4c6e308 to
5971462
Compare
88311d7 to
9689bab
Compare
|
I'm sorry but this PR raises a lot of forwards compatibility concerns for me. I'm concerned that it may limit our ability to add other features in the future. See #287 for prior discussion. |
|
I want to clarify the intended contract of The key point is that
In particular:
This means the API does not commit us to supporting unsplitting for all Given that this issue has existed for years and the use-cases are real today, I think a deliberately pessimistic |
|
To clarify how the current PR aligns with that contract: The implementation only attempts to merge when it can prove the two For There is one edge case I have not handled yet: merging when |
9689bab to
8f91fec
Compare
Closes #503, #287.
Bytes::unsplitandBytes::try_unsplitBytes::unsplitandBytes::try_unsplit