1use std::pin::Pin;
16use std::task::{Context, Poll};
17use tokio::io::{AsyncRead, ReadBuf};
18
19use crate::compress_index::TryGetIndex;
20use crate::{EtagResolvable, HashReaderDetector, Reader};
21
22pub struct WarpReader<R> {
23 inner: R,
24}
25
26impl<R: AsyncRead + Unpin + Send + Sync> WarpReader<R> {
27 pub fn new(inner: R) -> Self {
28 Self { inner }
29 }
30}
31
32impl<R: AsyncRead + Unpin + Send + Sync> AsyncRead for WarpReader<R> {
33 fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll<std::io::Result<()>> {
34 Pin::new(&mut self.inner).poll_read(cx, buf)
35 }
36}
37
38impl<R: AsyncRead + Unpin + Send + Sync> HashReaderDetector for WarpReader<R> {}
39
40impl<R: AsyncRead + Unpin + Send + Sync> EtagResolvable for WarpReader<R> {}
41
42impl<R: AsyncRead + Unpin + Send + Sync> TryGetIndex for WarpReader<R> {}
43
44impl<R: AsyncRead + Unpin + Send + Sync> Reader for WarpReader<R> {}