1
0
Fork 0
sqlite-reader/src/schema.rs

32 lines
755 B
Rust
Raw Normal View History

2022-07-30 15:34:12 +00:00
use crate::record::ColumnValue;
#[derive(Debug)]
pub struct Schema {
2022-07-04 20:22:40 +00:00
pub kind: String,
pub name: String,
pub table_name: String,
2022-11-14 10:49:48 +00:00
pub root_page: u32,
2022-07-26 07:57:26 +00:00
pub sql: String,
}
impl Schema {
/// Parses a record into a schema
2022-07-30 15:34:12 +00:00
pub fn parse(record: Vec<ColumnValue>) -> Option<Self> {
let mut items = record.into_iter();
2022-11-14 10:37:18 +00:00
let kind = items.next()?.to_string();
let name = items.next()?.to_string();
let table_name = items.next()?.to_string();
2022-11-14 10:49:48 +00:00
let root_page = items.next()?.read_u32();
2022-11-14 10:37:18 +00:00
let sql = items.next()?.to_string();
let schema = Self {
2022-07-30 15:34:12 +00:00
kind,
name,
table_name,
root_page,
2022-07-30 15:34:12 +00:00
sql,
};
Some(schema)
}
}