use std::io::Result;
use std::num::NonZeroUsize;
use std::pin::Pin;
use std::task::{Context, Poll};
mod cow;
pub use cow::*;
pub struct Iter<'a>(pub(super) CowIter<'a>);
impl<'a> Iter<'a> {
pub fn next(&mut self, max_chunk_len: Option<NonZeroUsize>) -> Option<Vec<u8>> {
self.0.next(|cc| cc.into_owned(), max_chunk_len)
}
pub fn into_cow(self) -> CowIter<'a> {
self.0
}
pub fn into_async(self) -> Result<AsyncIter<'a>> {
Ok(AsyncIter(self.0.into_async()?))
}
}
pub struct AsyncIter<'a>(AsyncCowIter<'a>);
impl AsyncIter<'_> {
pub fn poll_next(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
max_chunk_len: Option<NonZeroUsize>,
) -> Poll<Option<Vec<u8>>> {
let this = Pin::new(&mut self.get_mut().0);
this.poll_next(cx, |cc| cc.into_owned(), max_chunk_len)
}
pub async fn next(&mut self, max_chunk_len: Option<NonZeroUsize>) -> Option<Vec<u8>> {
self.0.next(|cc| cc.into_owned(), max_chunk_len).await
}
}