gluesql-core 0.20.0

GlueSQL - Open source SQL database engine fully written in Rust with pure functional execution layer, easily swappable storage and web assembly support!
Documentation
use {
    crate::{data::Value, executor::RowContext},
    std::rc::Rc,
};

#[derive(Clone, Debug, PartialEq)]
pub struct Row {
    pub columns: Rc<[String]>,
    pub values: Vec<Value>,
}

impl Row {
    pub fn get_value(&self, ident: &str) -> Option<&Value> {
        self.columns
            .iter()
            .position(|column| column == ident)
            .and_then(|index| self.values.get(index))
    }

    pub fn iter(&self) -> impl Iterator<Item = (&String, &Value)> {
        self.columns.iter().zip(self.values.iter())
    }

    pub fn into_values(self) -> Vec<Value> {
        self.values
    }

    pub fn as_context(&self) -> RowContext<'_> {
        RowContext::RefVecData {
            columns: &self.columns,
            values: &self.values,
        }
    }
}