use std::io::Result;
use std::pin::Pin;
use std::task::{Context, Poll};
use super::record::{Priv, Record};
mod cow;
pub use cow::*;
pub struct Iter<'a>(pub(super) CowIter<'a>);
impl<'a> Iter<'a> {
pub fn into_cow(self) -> CowIter<'a> {
self.0
}
pub fn into_async(self) -> Result<AsyncIter<'a>> {
Ok(AsyncIter(self.0.into_async()?))
}
}
impl Iterator for Iter<'_> {
type Item = (Priv, Record);
fn next(&mut self) -> Option<Self::Item> {
self.0.next(|cc, p| p.parse(cc))
}
}
pub struct AsyncIter<'a>(AsyncCowIter<'a>);
impl AsyncIter<'_> {
pub fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<(Priv, Record)>> {
let this = Pin::new(&mut self.get_mut().0);
this.poll_next(cx, |cc, p| p.parse(cc))
}
pub async fn next(&mut self) -> Option<(Priv, Record)> {
self.0.next(|cc, p| p.parse(cc)).await
}
}