1use serde::Serialize;
4
5#[derive(Debug, Clone, Default, Serialize)]
7pub struct Rows(pub Vec<Row>);
8
9impl Rows {
10 pub fn as_slice(&self) -> &[Row] {
12 &self.0
13 }
14
15 pub fn iter(&self) -> std::slice::Iter<'_, Row> {
17 self.0.iter()
18 }
19
20 pub fn len(&self) -> usize {
22 self.0.len()
23 }
24
25 pub fn is_empty(&self) -> bool {
27 self.0.is_empty()
28 }
29}
30
31impl IntoIterator for Rows {
32 type Item = Row;
33 type IntoIter = std::vec::IntoIter<Row>;
34
35 fn into_iter(self) -> Self::IntoIter {
36 self.0.into_iter()
37 }
38}
39
40#[derive(Debug, Clone, Serialize)]
43pub struct Row {
44 pub columns: Vec<String>,
46 pub values: Vec<serde_json::Value>,
48}
49
50impl Row {
51 pub fn get(&self, column: &str) -> Option<&serde_json::Value> {
53 let idx = self.columns.iter().position(|c| c == column)?;
54 self.values.get(idx)
55 }
56}