Skip to content

Commit 4daba1b

Browse files
author
git-user-cpp
committed
v0.1.0-remake
- implemented basic architecture
1 parent 4db0fb4 commit 4daba1b

File tree

7 files changed

+108
-4
lines changed

7 files changed

+108
-4
lines changed

src/Database/database.rs renamed to src/databases/database.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,18 @@
1414
*
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17-
*/
17+
*/
18+
19+
use super::tables::table::Table;
20+
21+
struct Database {
22+
tables: Vec<Table>,
23+
}
24+
25+
impl Database {
26+
pub fn new(tables: Vec<Table>) -> Self {
27+
Self {
28+
tables
29+
}
30+
}
31+
}

src/databases/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* NaiveSQL implemented in Rust.
3+
* Copyright (C) 2024 Andrew Kushyk
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
pub(crate) mod database;
20+
pub(crate) mod tables;

src/databases/tables/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* NaiveSQL implemented in Rust.
3+
* Copyright (C) 2024 Andrew Kushyk
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
pub(crate) mod table;
20+
pub(crate) mod rows;

src/Database/Table/table.rs renamed to src/databases/tables/rows/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414
*
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17-
*/
17+
*/
18+
19+
pub(crate) mod row;

src/Database/Table/Row/row.rs renamed to src/databases/tables/rows/row.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,16 @@
1414
*
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17-
*/
17+
*/
18+
19+
pub struct Row {
20+
columns: Vec<String>,
21+
}
22+
23+
impl Row {
24+
pub fn new(id: u32, columns: Vec<String>) -> Self {
25+
Self {
26+
columns,
27+
}
28+
}
29+
}

src/databases/tables/table.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* NaiveSQL implemented in Rust.
3+
* Copyright (C) 2024 Andrew Kushyk
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
use std::collections::HashMap;
20+
use crate::databases::tables::rows::row::Row;
21+
22+
pub struct Table {
23+
name: String,
24+
rows: HashMap<u32, Row>,
25+
}
26+
27+
impl Table {
28+
pub fn new(name: String, rows: HashMap<u32, Row>) -> Self {
29+
Self {
30+
name,
31+
rows,
32+
}
33+
}
34+
}

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414
*
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17-
*/
17+
*/
18+
19+
pub(crate) mod databases;

0 commit comments

Comments
 (0)