use candid::CandidType;
use icydb_core::value::OutputValue;
use serde::Deserialize;
pub use icydb_core::value::render_output_value_text;
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
pub struct RowProjectionOutput {
pub entity: String,
pub columns: Vec<String>,
pub rows: Vec<Vec<OutputValue>>,
pub row_count: u32,
}
impl RowProjectionOutput {
#[must_use]
pub fn rendered_rows(&self) -> Vec<Vec<String>> {
render_rows(self.rows.as_slice())
}
}
fn render_rows(rows: &[Vec<OutputValue>]) -> Vec<Vec<String>> {
rows.iter()
.map(|row| row.iter().map(render_output_value_text).collect())
.collect()
}