Conversation
@olix0r: Thank you for taking ownership for this :) Can you please elaborate what's holding the PR back? |
|
@Urhengulas Sorry, that comment is outdated (addressed in 34e60f7). It looks like there are some remaining changes needed in examples that I can try to fix. I won't be offended if someone else takes this branch and gets it over the line, though ;) |
|
Also, this is blocked on a few other PRs:
|
|
My h2 PR does pass CI hyperium/h2#497 |
|
@paolobarbolini whoops! didn't mean to double up on those PRs, I just didn't look before branching. Closed my open PRs in favor of yours. |
It probably just needs |
|
OK, build passes. gitcop won't tell me what it doesn't like(?!), so i'm going to rebase and force push. |
This changes updates the `bytes` dependency to v0.6.0.
8dd88fb to
25f3bfe
Compare
| } | ||
| let mut buf = ReadBuf::uninit(&mut self.read_buf.bytes_mut()[..]); | ||
| let dst = self.read_buf.bytes_mut(); | ||
| let dst = unsafe { &mut *(dst as *mut _ as *mut [MaybeUninit<u8>]) }; |
There was a problem hiding this comment.
That line looks threatening..
Can you please add a comment saying what it is doing?
There was a problem hiding this comment.
I don't actually know what it's doing ;)
I borrowed this from https://github.com/tokio-rs/tokio/blob/d78655337a68bded305782a8a8b4ac7be42aa6a7/tokio/src/io/util/read_buf.rs#L53-L55, which was the only updated use of ReadBuf::uninit I could find.
I would appreciate feedback from someone who understands these APIs better than I do.
There was a problem hiding this comment.
But let's see who introduced it 🙂
There was a problem hiding this comment.
Thanks, added a comment summarizing that discussion.
|
Don't worry about gitcop (it's not "required"), it's just a reminder to me to fix the commit message format. |
| let dst = self.read_buf.bytes_mut(); | ||
| // Safety: `dst` may include uninitialized memory, but `ReadBuf` will | ||
| // never uninitialize memory that has already been initialized. | ||
| let dst = unsafe { &mut *(dst as *mut _ as *mut [MaybeUninit<u8>]) }; | ||
| let mut buf = ReadBuf::uninit(dst); | ||
| match Pin::new(&mut self.io).poll_read(cx, &mut buf) { |
There was a problem hiding this comment.
An alternative to all of this (which avoids the scary-looking pointer cast that @Urhengulas was concerned about) is to just use tokio_util::io::poll_read_buf from the latest tokio-util here:
| let dst = self.read_buf.bytes_mut(); | |
| // Safety: `dst` may include uninitialized memory, but `ReadBuf` will | |
| // never uninitialize memory that has already been initialized. | |
| let dst = unsafe { &mut *(dst as *mut _ as *mut [MaybeUninit<u8>]) }; | |
| let mut buf = ReadBuf::uninit(dst); | |
| match Pin::new(&mut self.io).poll_read(cx, &mut buf) { | |
| match tokio_util::io::poll_read_buf(Pin::new(&mut self.io), cx, &mut self.read_buf) { |
That would mean adding a tokio-util dependency, but it's already a transitive dependency via h2.
There was a problem hiding this comment.
That seems like a good solution!
And this is a useful function which can't be found in the docs... (code: https://github.com/tokio-rs/tokio/blob/master/tokio-util/src/lib.rs#L67-L134).
|
I believe #2339 closes this. |
Depends on: