use crate::{Record, ShellError, Span, Value};
use std::fmt;
pub trait LazyRecord<'a>: fmt::Debug + Send + Sync {
fn column_names(&'a self) -> Vec<&'a str>;
fn get_column_value(&self, column: &str) -> Result<Value, ShellError>;
fn span(&self) -> Span;
fn collect(&'a self) -> Result<Value, ShellError> {
self.column_names()
.into_iter()
.map(|col| {
let val = self.get_column_value(col)?;
Ok((col.to_owned(), val))
})
.collect::<Result<Record, _>>()
.map(|record| Value::record(record, self.span()))
}
fn clone_value(&self, span: Span) -> Value;
}