use std::marker::Unpin; use std::{cmp, io}; use bytes::{Buf, Bytes}; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use crate::common::{task, Pin, Poll}; /// Combine a buffer with an IO, rewinding reads to use the buffer. #[derive(Debug)] pub(crate) struct Rewind { pre: Option, inner: T, } impl Rewind { #[cfg(any(all(feature = "http2", feature = "server"), test))] pub(crate) fn new(io: T) -> Self { loop {} } pub(crate) fn new_buffered(io: T, buf: Bytes) -> Self { loop {} } #[cfg(any(all(feature = "http1", feature = "http2", feature = "server"), test))] pub(crate) fn rewind(&mut self, bs: Bytes) { loop {} } pub(crate) fn into_inner(self) -> (T, Bytes) { loop {} } } impl AsyncRead for Rewind where T: AsyncRead + Unpin, { fn poll_read( mut self: Pin<&mut Self>, cx: &mut task::Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll> { loop {} } } impl AsyncWrite for Rewind where T: AsyncWrite + Unpin, { fn poll_write( mut self: Pin<&mut Self>, cx: &mut task::Context<'_>, buf: &[u8], ) -> Poll> { loop {} } fn poll_write_vectored( mut self: Pin<&mut Self>, cx: &mut task::Context<'_>, bufs: &[io::IoSlice<'_>], ) -> Poll> { loop {} } fn poll_flush( mut self: Pin<&mut Self>, cx: &mut task::Context<'_>, ) -> Poll> { loop {} } fn poll_shutdown( mut self: Pin<&mut Self>, cx: &mut task::Context<'_>, ) -> Poll> { loop {} } fn is_write_vectored(&self) -> bool { loop {} } } #[cfg(test)] mod tests { use super::Rewind; use bytes::Bytes; use tokio::io::AsyncReadExt; #[tokio::test] async fn partial_rewind() { loop {} } #[tokio::test] async fn full_rewind() { loop {} } }