use super::types::{Row, Schema};
use sochdb_core::Result;
pub trait PlanNode {
fn schema(&self) -> &Schema;
fn next(&mut self) -> Result<Option<Row>>;
fn reset(&mut self) -> Result<()> {
Ok(()) }
fn collect_all(&mut self) -> Result<Vec<Row>> {
let mut rows = Vec::new();
while let Some(row) = self.next()? {
rows.push(row);
}
Ok(rows)
}
}
impl PlanNode for Box<dyn PlanNode> {
fn schema(&self) -> &Schema {
(**self).schema()
}
fn next(&mut self) -> Result<Option<Row>> {
(**self).next()
}
fn reset(&mut self) -> Result<()> {
(**self).reset()
}
}