use std::{
io::Read,
pin::Pin,
task::{Context, Poll},
};
use futures::AsyncRead;
use super::{BytesReader, DynamicChain};
impl AsyncRead for BytesReader<'_> {
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<std::io::Result<usize>> {
let p = self.get_mut();
match p.read(buf) {
Ok(size) => Poll::Ready(Ok(size)),
Err(e) => Poll::Ready(Err(e)),
}
}
}
impl AsyncRead for DynamicChain<'_> {
fn poll_read(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<std::io::Result<usize>> {
let p = self.get_mut();
match p.read(buf) {
Ok(size) => Poll::Ready(Ok(size)),
Err(e) => Poll::Ready(Err(e)),
}
}
}