-
Notifications
You must be signed in to change notification settings - Fork 85
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
write method calls send_data before poll_ready #78
Comments
Huh, good point. I don't recall why the order was switched there... Granted, technically we aren't using |
Another option would be to rename the methods to something like But if we're considering an API change, I'm not sure why we couldn't just change it to: fn poll_send_data(&mut self, buf: &mut dyn Buf) -> Poll<Result<()>>; It would remove the need for the stream implementation to convert/store the buffer and make things a bit simpler, IMO. |
That change would require that the bytes always be copied out, no? I guess unless it was already a |
Not necessarily. If the caller used let len = buf.chunk().len();
let bytes = buf.copy_to_bytes(len); (see, for example, |
Yea, that's what I meant by if it was already a |
This changes the `quic::SendStream` trait to closer mimic the `AsyncWrite` trait, but using a `impl Buf` rather than `&[u8]` which removes the need to allocate and copy the byte slice to store it if needed. [s2n-quic::SendStream](https://github.com/aws/s2n-quic/blob/bf20c6dd148153802929a2514b444dcf5dd37fd1/quic/s2n-quic-h3/src/s2n_quic.rs#L364) uses this to enqueue the bytes for sending, which would require allocating if `&[u8]` was used. Issue hyperium#78 discusses this API change which would remove the need for intermediate buffering. See: hyperium#78 (comment)
On stream.rs#L28-L29,
stream.send_data
is called prior tostream.poll_ready
.stream.poll_ready
should be called first, similar to as described in https://docs.rs/futures/latest/futures/sink/trait.Sink.html#tymethod.poll_ready.Thanks for considering this issue, and let me know if you have any questions!
The text was updated successfully, but these errors were encountered: