use std::{
io::{self, SeekFrom},
pin::Pin,
task::{Context, Poll},
};
use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite, ReadBuf};
#[derive(Debug)]
pub struct EmptySeekableReader;
#[derive(Debug)]
pub struct EmptySeekableWriter;
pub trait SeekableReader: AsyncRead + AsyncSeek {}
pub trait SeekableWriter: AsyncWrite + AsyncSeek {}
impl<T> SeekableReader for T where T: AsyncRead + AsyncSeek {}
impl<T> SeekableWriter for T where T: AsyncWrite + AsyncSeek {}
impl AsyncRead for EmptySeekableReader {
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
_buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> {
Poll::Ready(Ok(()))
}
}
impl AsyncSeek for EmptySeekableReader {
fn start_seek(self: Pin<&mut Self>, _position: SeekFrom) -> io::Result<()> {
Ok(())
}
fn poll_complete(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<io::Result<u64>> {
Poll::Ready(Ok(0))
}
}