Skip to content

Commit be894ba

Browse files
committed
WIP memory backend
1 parent 8ab1e53 commit be894ba

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
mod ast;
22
mod lexer;
3+
mod mem_backend;
34
mod parser;
45
use parser::parse;
56

src/mem_backend.rs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
pub enum ColumnType {
2+
TextType,
3+
IntType,
4+
}
5+
6+
pub trait Backend {
7+
fn create(&self) -> Result<(), ()>;
8+
fn insert(&self) -> Result<(), ()>;
9+
fn update(&self) -> Result<(), ()>;
10+
}
11+
12+
trait Cell {
13+
fn as_text(&self) -> String;
14+
fn as_int(&self) -> u32;
15+
}
16+
17+
pub struct Column {
18+
col_type: ColumnType,
19+
col_name: String,
20+
}
21+
22+
type MemCell = Vec<u8>;
23+
24+
impl Cell for MemCell {
25+
fn as_int(&self) -> u32 {
26+
return 1;
27+
}
28+
29+
fn as_text(&self) -> String {
30+
return String::new();
31+
}
32+
}
33+
34+
pub struct Results {
35+
pub columns: Vec<Column>,
36+
pub rows: Vec<Vec<MemCell>>,
37+
}

0 commit comments

Comments
 (0)