diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2020-10-27 09:30:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-27 09:30:29 +0100 |
commit | fe2b9976755407b85c82b5cdee9d8c5e16e3d6c6 (patch) | |
tree | 65d9278870691e102cbcc8122782fe75104d2894 /tokio-util/src/lib.rs | |
parent | 6d0ba19af51015dcd80558ae768215448e285fdf (diff) |
util: upgrade tokio-util to bytes 0.6 (#3052)
Diffstat (limited to 'tokio-util/src/lib.rs')
-rw-r--r-- | tokio-util/src/lib.rs | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/tokio-util/src/lib.rs b/tokio-util/src/lib.rs index 10b828ef..1e4b9d40 100644 --- a/tokio-util/src/lib.rs +++ b/tokio-util/src/lib.rs @@ -57,37 +57,3 @@ pub mod either; #[cfg(feature = "time")] pub mod time; - -#[cfg(any(feature = "io", feature = "codec"))] -mod util { - use tokio::io::{AsyncRead, ReadBuf}; - - use bytes::BufMut; - use futures_core::ready; - use std::io; - use std::pin::Pin; - use std::task::{Context, Poll}; - - pub(crate) fn poll_read_buf<T: AsyncRead>( - cx: &mut Context<'_>, - io: Pin<&mut T>, - buf: &mut impl BufMut, - ) -> Poll<io::Result<usize>> { - if !buf.has_remaining_mut() { - return Poll::Ready(Ok(0)); - } - - let orig = buf.bytes_mut().as_ptr() as *const u8; - let mut b = ReadBuf::uninit(buf.bytes_mut()); - - ready!(io.poll_read(cx, &mut b))?; - let n = b.filled().len(); - - // Safety: we can assume `n` bytes were read, since they are in`filled`. - assert_eq!(orig, b.filled().as_ptr()); - unsafe { - buf.advance_mut(n); - } - Poll::Ready(Ok(n)) - } -} |