use crate::raw::row::DuckRow;
#[derive(Debug, Clone)]
pub struct ResultSet {
rows: Vec<DuckRow>,
changes: u64,
column_names: Box<[Box<str>]>,
}
impl ResultSet {
pub(crate) fn new(
rows: Vec<DuckRow>,
changes: u64,
column_names: Box<[Box<str>]>,
) -> ResultSet {
ResultSet { rows, changes, column_names }
}
pub fn rows(&self) -> &[DuckRow] {
&self.rows
}
pub fn into_rows(self) -> Vec<DuckRow> {
self.rows
}
pub fn changes(&self) -> u64 {
self.changes
}
pub fn column_names(&self) -> &[Box<str>] {
&self.column_names
}
pub fn len(&self) -> usize {
self.rows.len()
}
pub fn is_empty(&self) -> bool {
self.rows.is_empty()
}
pub fn first(&self) -> Option<&DuckRow> {
self.rows.first()
}
}
impl IntoIterator for ResultSet {
type Item = DuckRow;
type IntoIter = std::vec::IntoIter<DuckRow>;
fn into_iter(self) -> Self::IntoIter {
self.rows.into_iter()
}
}
impl<'a> IntoIterator for &'a ResultSet {
type Item = &'a DuckRow;
type IntoIter = std::slice::Iter<'a, DuckRow>;
fn into_iter(self) -> Self::IntoIter {
self.rows.iter()
}
}