#![allow(clippy::needless_lifetimes, clippy::elidable_lifetime_names)]
use crate::future::BoxFuture;
use std::future::Future;
use crate::error::Result;
use crate::schema::{ColumnHeader, Row};
pub trait RowStream: Send {
fn columns(&self) -> &[ColumnHeader];
fn next_row(&mut self) -> impl Future<Output = Result<Option<Row>>> + Send;
fn close(self: Box<Self>) -> impl Future<Output = Result<()>> + Send;
}
pub trait DynRowStream: Send {
fn columns(&self) -> &[ColumnHeader];
fn next_row<'a>(&'a mut self) -> BoxFuture<'a, Result<Option<Row>>>;
fn close(self: Box<Self>) -> BoxFuture<'static, Result<()>>;
}
impl<T> DynRowStream for T
where
T: RowStream + 'static,
{
fn columns(&self) -> &[ColumnHeader] {
<Self as RowStream>::columns(self)
}
fn next_row<'a>(&'a mut self) -> BoxFuture<'a, Result<Option<Row>>> {
Box::pin(<Self as RowStream>::next_row(self))
}
fn close(self: Box<Self>) -> BoxFuture<'static, Result<()>> {
Box::pin(<Self as RowStream>::close(self))
}
}