use crate::table::Row;
#[derive(Debug, Clone)]
pub struct MemoryStorage {
rows: Vec<Row>,
}
impl MemoryStorage {
pub fn new() -> Self {
Self { rows: Vec::new() }
}
#[allow(dead_code)]
pub fn with_rows(rows: Vec<Row>) -> Self {
Self { rows }
}
pub fn row_count(&self) -> usize {
self.rows.len()
}
pub fn rows(&self) -> &[Row] {
&self.rows
}
pub fn rows_mut(&mut self) -> &mut Vec<Row> {
&mut self.rows
}
pub fn push_row(&mut self, row: Row) {
self.rows.push(row);
}
pub fn replace_rows(&mut self, rows: Vec<Row>) {
self.rows = rows;
}
}
impl Default for MemoryStorage {
fn default() -> Self {
Self::new()
}
}